Reputation: 14183
I'm using ConcatenatingMediaSource
to play many MediaSource
seaminglessly, which is tons of fun, but I can't find a way to receive a callback when the player starts playing the next MediaSource
.
ExoPlayer.EventLister.onTracksChanged(TrackGroupArray, TrackSelected)
gets called when the MediaSource
changes (I can hear the new track at that point), so it seems like the right place but how can I retrieve the index of the MediaSource
being played?
MediaSource[] allSources = // ...
ConcatenatingMediaSource source = new ConcatenatingMediaSource(allSources);
ExoPlayer player = // ..
player.prepare(source);
// ...
@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
// Can I retrieve the index of the MediaSource currently being played here?
// If not, where!?
}
Upvotes: 4
Views: 3195
Reputation: 14183
apparently the right callback is onPositionDiscontinuity()
and the method to get the index of the current MediaSource
being played is ExoPlayer.getCurrentWindowIndex()
@Override
public void onPositionDiscontinuity() {
int sourceIndex = player.getCurrentWindowIndex();
}
Upvotes: 5