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

Ignore load errors in subtitle tracks sideloaded using SingleSampleMediaSource #3140

Closed
minaEweida opened this issue Aug 4, 2017 · 5 comments
Assignees

Comments

@minaEweida
Copy link

minaEweida commented Aug 4, 2017

I am using MergingMediaSource in order to display Video and subtitles. For some reason the text source file might be removed from the server so the url will return 404, giving the following exception com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 404

At this point it makes sense, the problem is I can't play the video if this happens although I expect that if the text source is not found, I could at least play the video.

Below you can find the code snippet for preparing the media links

MediaSource videoSource = new ExtractorMediaSource(mp4VideoUri, dataSourceFactory, extractorsFactory, null, null);

Format textFormat;
MediaSource[] mediaSources = new MediaSource[videoDetailsModel.getVideoSubtitleModels().size() + 1];
mediaSources[0] = videoSource;
for (int i = 0; i < videoSubtitleModels.size(); i++) {
  VideoSubtitleModel videoSubtitleModel = videoSubtitleModels.get(i);
  textFormat = Format.createTextSampleFormat(null, videoSubtitleModel.getCaptionMimeType(), null, Format.NO_VALUE, Format.NO_VALUE, videoSubtitleModel.getCaptionSrcLang(), null);
  mediaSources[i + 1] = new 
  SingleSampleMediaSource(Uri.parse(videoSubtitleModel.getCaptioningUrl()), dataSourceFactory, textFormat, C.TIME_UNSET);
}
MediaSource mediaSourceWithText = new MergingMediaSource(mediaSources);

// Prepare the player with the source.
player.prepare(mediaSourceWithText);
@pedromfmachado
Copy link
Contributor

Did you fins any solution for this? I'm facing the same issue

@minaEweida
Copy link
Author

The only solution I have now is to validate each Text Url before passing it to exoplayer.

@AquilesCanta
Copy link
Contributor

Let's use this issue to track relaxing loading errors for the SingleSampleMediaSource to allow playback to continue in these cases.

@pedromfmachado
Copy link
Contributor

pedromfmachado commented Oct 13, 2017

@AquilesCanta I have a similar issue:
I have several ExtractorMediaSource loaded with a MergingMediaSource and if one of them does not exist (404 error) the player fails to play. Is this the expected behaviour even it all the other sources exist and are functioning correctly?

ojw28 pushed a commit that referenced this issue Nov 7, 2017
…rors

This prevents users from having to check sideloaded subtitles URLs before
preparing a SingleSampleMediaSource with it.

Issue:#3140

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=174475274
@ojw28
Copy link
Contributor

ojw28 commented Nov 7, 2017

As of the change above, it's possible to configure SingleSampleMediaSource to treat load failures in a way that doesn't cause an error to be propagated. @pedromfmachado - Yes that's expected, and your use case is different to the one tracked here. Please file a separate issue.

@ojw28 ojw28 closed this as completed Nov 7, 2017
ojw28 pushed a commit that referenced this issue Nov 13, 2017
…rors

This prevents users from having to check sideloaded subtitles URLs before
preparing a SingleSampleMediaSource with it.

Issue:#3140

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=174475274
@google google deleted a comment from talhatariq Dec 18, 2017
@google google locked and limited conversation to collaborators Mar 25, 2018
@AquilesCanta AquilesCanta changed the title Video does not play if Closed captions link is not found Ignore load errors in subtitle tracks sideloaded using SingleSampleMediaSource Jul 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants