Skip to content

Instantly share code, notes, and snippets.

@q-litzler
Last active May 14, 2017 14:05
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 q-litzler/663d29d7ff108530203ea8d8579cea1c to your computer and use it in GitHub Desktop.
Save q-litzler/663d29d7ff108530203ea8d8579cea1c to your computer and use it in GitHub Desktop.
ConcatenatingMediaSource WindowIndex change
var currentIndex: Int = 0
var player : ExoPlayer
var handler = Handler()
fun onNewWindowIndex(index: Int) {
currentIndex = index
// Do something with your playlist using this reliable index
}
class PlayerEventListener: ExoPlayer.Listener {
override fun onPositionDiscontinuity() {
if (currentIndex != player.currentWindowIndex) {
onNewWindowIndex(player.currentWindowIndex)
}
}
}
class PlayerLoadControl: LoadControl {
override fun onPrepared() {
handler.post {
onNewWindowIndex(player.currentWindowIndex)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment