Looked at StackOverflow and other issues. Could not find anything related
I using the new playlist API provided with v2.12.0 and loading multiple MediaItems into the player. One of the sources throws an ExoPlaybackException of ExoPlaybackException.TYPE_SOURCE type.
How do I know which media item this relates to?
No specific bug is referred to.
General question that does not relate to a specific source.
I think in this case the field ExoPlaybackException.mediaPeriodId has a media period id assigned (it is not null). If so you can do something like this:
MediaSource.MediaPeriodId mediaPeriodId = playbackException.mediaPeriodId;
int windowIndex = player.getCurrentTimeline()
.getPeriodByUid(mediaPeriodId.periodUid, new Timeline.Period()).windowIndex;
player.removeMediaItem(windowIndex);
Please note, that the above assumes that you are having a 1:1 relationship between media items and windows in the timeline. This means you are not using a ConcatenatingMediaSource. In case you are only using the new API with MediaItem you are fine.
Please let me know whether that works for you.
You can also use AnalyticsListener and listen to onPlayerError which has an EventTime argument with a windowIndex field. This is essentially equivalent to the proposal above, but easier to read in code:
@Override
public void onPlayerError(EventTime eventTime, ExoPlaybackException e) {
Log.e("ERROR", "Media item number " + eventTime.windowIndex + " failed.");
}
Thanks a lot for the fast answers, this solves my problem. 馃檪 馃檱
Cool, thanks for letting us know. I'm closing this issue. Please re-open if you think it is needed.
Most helpful comment
You can also use
AnalyticsListenerand listen toonPlayerErrorwhich has anEventTimeargument with awindowIndexfield. This is essentially equivalent to the proposal above, but easier to read in code: