Last active
January 29, 2023 10:47
-
-
Save ademirqueiroga/8cdbdd0af9494f5da6a4454e43c01121 to your computer and use it in GitHub Desktop.
BasicMediaPlayerAdapter.kt
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 BasicMediaPlayerAdapter(context: Context) : MediaPlayerAdapter(context) { | |
val playlist = ArrayList<Movie>() | |
var playlistPosition = 0 | |
private set | |
override fun next() = loadMovie((playlistPosition + 1).mod(playlist.size)) | |
override fun previous() = loadMovie((playlistPosition - 1).mod(playlist.size)) | |
override fun fastForward() = seekTo(currentPosition + 10_000) | |
override fun rewind() = seekTo(currentPosition - 10_000) | |
override fun getSupportedActions(): Long { | |
return (ACTION_SKIP_TO_PREVIOUS xor | |
ACTION_REWIND xor | |
ACTION_PLAY_PAUSE xor | |
ACTION_FAST_FORWARD xor | |
ACTION_SKIP_TO_NEXT).toLong() | |
} | |
fun loadMovie(playlistPosition: Int) { | |
this.playlistPosition = playlistPosition | |
setDataSource(Uri.parse(playlist[playlistPosition].videoUrl)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment