Last active
May 14, 2017 14:05
-
-
Save q-litzler/663d29d7ff108530203ea8d8579cea1c to your computer and use it in GitHub Desktop.
ConcatenatingMediaSource WindowIndex change
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
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