Skip to content

Is there a method for source fallback? #7235

Answered by gkatsev
kinetachien asked this question in Q&A
Discussion options

You must be logged in to vote

There isn't really an automatic way to change sources if there is an error during playback. Your best bet is to listen to the error event and then set a new source.
For example:

player.one('error', function() {
  player.src({
    src:: 'newsource.m3u8',
    type: 'application/x-mpegurl'
  });
});

On a separate note, we have a new option in Video.js 7.12 called retryOnError. When set, this will choose a different source if the source fails to load on initial source setting.
For example:

<video-js id="vid" controls>
  <source src="source1.m3u8" type="application/x-mpegurl">
  <source src="source2.mp4" type="video/mp4">
</video-js>
const player = videojs('vid', {
  retryOnError: true
});

So,…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@phloxic
Comment options

@gkatsev
Comment options

Answer selected by gkatsev
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants