Created
March 15, 2023 00:32
-
-
Save ademirqueiroga/f15fcf6238ec3a59514ca25badfb1e18 to your computer and use it in GitHub Desktop.
SimplePlaybackTransportControlGlue player listeners
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SimplePlaybackTransportControlGlue(...) { | |
... | |
override fun onPlayCompleted() { | |
super.onPlayCompleted() | |
playbackState = PlaybackStateCompat.STATE_NONE | |
} | |
fun onStartBuffering() { | |
playbackState = PlaybackStateCompat.STATE_BUFFERING | |
} | |
fun onFinishedBuffering() { | |
playbackState = when (isPlaying) { | |
true -> PlaybackStateCompat.STATE_PLAYING | |
else -> PlaybackStateCompat.STATE_PAUSED | |
} | |
} | |
fun rewind() { | |
playbackState = PlaybackStateCompat.STATE_REWINDING | |
seekTo(currentPosition - 10_000) | |
} | |
fun fastForward() { | |
playbackState = PlaybackStateCompat.STATE_FAST_FORWARDING | |
seekTo(currentPosition + 10_000) | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment