Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ademirqueiroga/f15fcf6238ec3a59514ca25badfb1e18 to your computer and use it in GitHub Desktop.
Save ademirqueiroga/f15fcf6238ec3a59514ca25badfb1e18 to your computer and use it in GitHub Desktop.
SimplePlaybackTransportControlGlue player listeners
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