Skip to content

Instantly share code, notes, and snippets.

@ademirqueiroga
Last active January 29, 2023 12:04
Show Gist options
  • Save ademirqueiroga/78f1a0ec7516ac6cbeb3a3d364dcf7ea to your computer and use it in GitHub Desktop.
Save ademirqueiroga/78f1a0ec7516ac6cbeb3a3d364dcf7ea to your computer and use it in GitHub Desktop.
Update BaseTransportControlGlue content information
val currentMovie: Movie
get() = playerAdapter.playlist[playerAdapter.playlistPosition]
// Event when ready state for play changes.
override fun onPreparedStateChanged() {
super.onPreparedStateChanged()
playWhenPrepared()
updateMovieInfo(currentMovie)
}
private fun updateMovieInfo(movie: Movie?) {
title = movie?.title
subtitle = movie?.description
}
fun loadMovie(playlistPosition: Int) {
playerAdapter.loadMovie(playlistPosition)
}
fun setPlaylist(movies: List<Movie>) {
playerAdapter.playlist.clear()
playerAdapter.playlist.addAll(movies)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment