Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FEC-13166): add validation for tracks unsupported #809

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
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