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

Immediately restart the player if an error occurs #6744

Closed
Raino opened this issue Jul 7, 2020 · 9 comments · Fixed by videojs/http-streaming#893
Closed

Immediately restart the player if an error occurs #6744

Raino opened this issue Jul 7, 2020 · 9 comments · Fixed by videojs/http-streaming#893

Comments

@Raino
Copy link

Raino commented Jul 7, 2020

Hello!
I found a similar problem (videojs/videojs-contrib-hls#902, #1805, #3725, videojs/videojs-contrib-hls#1030) and did not fully understand the final way to solve it.
I tried it:

var options = {
  plugins: {
    reloadSourceOnError: {}
  }
};
var player = videojs('myVideo', options);

but the player still returned an error and did not restart.
Please help us figure out how to solve this problem.
Thanks!

@gkatsev
Copy link
Member

gkatsev commented Jul 7, 2020

I tried it locally with initializing the plugin in the player options. Then, I ran player.error({code: 4}) and I could see the player reload the current source.
Can you create a live minimal, complete, verifiable example you can share?

@Raino
Copy link
Author

Raino commented Jul 7, 2020

@gkatsev It will be difficult, but I can try. But first I want to clarify, during your initialization, the player did not show any error messages at all? Perhaps you can send me Your code and I will try to compare it with my own? Where you connect libraries, which ones, how you call them, and so on.

@gkatsev
Copy link
Member

gkatsev commented Jul 7, 2020

So, I was going to make an example and noticed that it was working with HLS or DASH videos but not with mp4s. This is because the plugin was specifically written with our playback engine in mind and was never tested with other sources.
The example page: https://codepen.io/gkatsev/pen/GRoxYwX?editors=1010
You can comment out the mp4 or the m3u8 to try one or the other and then click on the "create a fake error" button to trigger a fake error that will cause the source to reload for the m3u8 but not for the mp4.

gkatsev added a commit to videojs/http-streaming that referenced this issue Jul 7, 2020
Previously, we were getting the source from tech.currentSource_. This
only gets set when a source handler like VHS is used. However, because
VHS is in Video.js by default and the plugin is global, some people are
using this plugin for other sources as well.

There isn't a reason why we should be relying on tech.currentSource_
over player.currentSource() when we have access to the player in the
plugin.

Fixes videojs/video.js#6744
@gkatsev
Copy link
Member

gkatsev commented Jul 7, 2020

Made a PR with a fix videojs/http-streaming#893.

gkatsev added a commit to videojs/http-streaming that referenced this issue Jul 8, 2020
* fix: have reloadSourceOnError get src from player

Previously, we were getting the source from tech.currentSource_. This
only gets set when a source handler like VHS is used. However, because
VHS is in Video.js by default and the plugin is global, some people are
using this plugin for other sources as well.

There isn't a reason why we should be relying on tech.currentSource_
over player.currentSource() when we have access to the player in the
plugin.

Fixes videojs/video.js#6744
@Raino
Copy link
Author

Raino commented Jul 8, 2020

@gkatsev I tried creating the error twice. The first time everything worked, and the second time the video was not interrupted, but an error message appeared on top of the player and it did not go away

@gkatsev
Copy link
Member

gkatsev commented Jul 8, 2020

The plugin is set up to not retry if there are multiple errors in quick succession. If you need that, you'll want to write your own plugin (or make edits based on the existing piece of code).

@Raino
Copy link
Author

Raino commented Jul 8, 2020

@gkatsev In #3725 in the message from brodjustice was an example of the code. I take it it's just for restarting the player? Can you tell me if it's relevant? Since I see working with objects of the .rtmp-video-js classes there. Or perhaps there are other ways to make the player initialization cyclic?

@Raino
Copy link
Author

Raino commented Jul 9, 2020

@gkatsev Maybe You can advise me some methods or plug-ins, so that when the HLS stream is bad, the player does not give an error, but always tries to connect?

@Feofilakt
Copy link

Feofilakt commented Sep 29, 2021

@gkatsev, Unfortunatly, your example doesn't work. Steps:

  1. Play
  2. Enable the dev tools "network blocking" feature for address "https://d2zihajmogu5jn.cloudfront.net"
  3. Wait until player stopped
  4. Disable "network blocking"

image

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants