Is there a method for source fallback? #7235
-
I'm working on a project that runs a live video stream that isn't always running. I need to have a fallback video but the normal way - adding a second source file - doesn't work. Is there documentation on this? Any advice? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
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 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 <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, with the above example, assuming that Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Thanks much for the replies. FWIW I ended up using readyState() along with a javascript timeout and it's working great. I had first used the error function but it took too long to check and load the fallback. setTimeout(function () { |
Beta Was this translation helpful? Give feedback.
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:
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:
So,…