Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,10 @@ public void onPositionDiscontinuity(@NonNull Player.PositionInfo oldPosition, @N
public void onTracksChanged(@NonNull Tracks tracks) {
log.d("onTracksChanged");

if (!isTypeSupportedTracks(tracks)) {
return;
}

//if onTracksChanged happened when application went background, do not update the tracks.
if (assertTrackSelectionIsNotNull("onTracksChanged()")) {
//if the track info new -> map the available tracks. and when ready, notify user about available tracks.
Expand All @@ -1081,6 +1085,28 @@ public void onTracksChanged(@NonNull Tracks tracks) {
}
}

private boolean isTypeSupportedTracks(@NonNull Tracks tracks) {
if (tracks.containsType(C.TRACK_TYPE_VIDEO)
&& !tracks.isTypeSupported(C.TRACK_TYPE_VIDEO, /* allowExceedsCapabilities= */ true)) {
String errorMessage = "Media includes video tracks, but none are playable by this device";
currentError = new PKError(PKPlayerErrorType.SOURCE_ERROR, PKError.Severity.Fatal, errorMessage, new IllegalArgumentException(errorMessage));
if (eventListener != null) {
eventListener.onEvent(PlayerEvent.Type.ERROR);
}
return false;
}
if (tracks.containsType(C.TRACK_TYPE_AUDIO)
&& !tracks.isTypeSupported(C.TRACK_TYPE_AUDIO, /* allowExceedsCapabilities= */ true)) {
String errorMessage = "Media includes audio tracks, but none are playable by this device";
currentError = new PKError(PKPlayerErrorType.SOURCE_ERROR, PKError.Severity.Fatal, errorMessage, new IllegalArgumentException(errorMessage));
if (eventListener != null) {
eventListener.onEvent(PlayerEvent.Type.ERROR);
}
return false;
}
return true;
}

@Override
public void onVideoInputFormatChanged(@NonNull Format format) {
if (assertTrackSelectionIsNotNull("onVideoInputFormatChanged")) {
Expand Down