* Add ability to swipe up and down to adjust volume Created AudioController to adjust global volume for media channel. Alarm, system and other volume levels are unaffected. This way it doesn't need specific implementation for separate players. During swiping system volume slider is shown and it is possible to change direction mid-swipe. AudioController should probably be singleton and provided by DI but currently PlayerActivity is handling all the playback so it seemed unnecessarily complicated. Sensitivity can be adjusted by threshold value in VerticalSwipeListener. * Add audio controller class Co-authored-by: Jarne Demeulemeester <32322857+jarnedemeulemeester@users.noreply.github.com>
18 lines
No EOL
779 B
Kotlin
18 lines
No EOL
779 B
Kotlin
package dev.jdtech.jellyfin.utils
|
|
|
|
import android.content.Context
|
|
import android.media.AudioManager
|
|
import android.media.AudioManager.ADJUST_LOWER
|
|
import android.media.AudioManager.ADJUST_RAISE
|
|
import android.media.AudioManager.ADJUST_SAME
|
|
import android.media.AudioManager.FLAG_SHOW_UI
|
|
import android.media.AudioManager.STREAM_MUSIC
|
|
|
|
internal class AudioController internal constructor(context: Context) {
|
|
|
|
private val manager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
|
|
|
fun volumeUp() = manager.adjustStreamVolume(STREAM_MUSIC, ADJUST_RAISE, FLAG_SHOW_UI)
|
|
fun volumeDown() = manager.adjustStreamVolume(STREAM_MUSIC, ADJUST_LOWER, FLAG_SHOW_UI)
|
|
fun showVolumeSlider() = manager.adjustStreamVolume(STREAM_MUSIC, ADJUST_SAME, FLAG_SHOW_UI)
|
|
} |