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

added hls error recovery #355

Closed
wants to merge 4 commits into from
Closed

added hls error recovery #355

wants to merge 4 commits into from

Conversation

iambumblehead
Copy link

add attempt to recover from hls errors

@iambumblehead
Copy link
Author

@cookpete it seems travic-ci is unable to complete the test sequence. Would you take a look at my PR?

@cookpete
Copy link
Owner

It seems like a MEDIA_ERROR is occuring pretty consistently when seeking towards the end of a HLS video. recoverMediaError() is causing a loop to occur as it attempts to play the media immediately and causes another MEDIA_ERROR, whereas the demo video seems to recover automatically without having to call recoverMediaError().

I think we are better off passing Hls.Events.ERROR through to the onError callback, and possibly passing through the hls object. Then users can just implement any sort of recovery logic that they want.

@cookpete cookpete closed this in 8c101e9 Mar 15, 2018
@cookpete
Copy link
Owner

As of 1.3.0, hls.js errors are now passed as onError(e, data, hlsInstance, hlsGlobal)

You could implement the same recovery logic like so:

function onError (e, data, hlsInstance, hlsGlobal) {
  if (!hlsGlobal) {
    // Probably not a HLS error
    return
  }
  switch (data.type) {
    case hlsGlobal.ErrorTypes.NETWORK_ERROR:
      // try to recover network error
      // hls: fatal network error encountered, trying to recover
      hlsInstance.startLoad()
      break
    case hlsGlobal.ErrorTypes.MEDIA_ERROR:
      // hls: fatal media error encountered, trying to recover
      hlsInstance.recoverMediaError()
      break
    default:
      // cannot recover
      hlsInstance.destroy()
      break
  }
}

<ReactPlayer url={HLS_URL} onError={onError} />

Although beware of causing loops when seeking.

@iambumblehead
Copy link
Author

@cookpete I copied your recommendation here. its a great starting point :), thanks

@cookpete cookpete mentioned this pull request May 4, 2018
david-hub024 pushed a commit to david-hub024/React_VideoPlayer that referenced this pull request Dec 23, 2018
Dealing with errors within ReactPlayer just caused more bugs
Closes cookpete/react-player#354
Closes cookpete/react-player#355
david-hub024 pushed a commit to david-hub024/React_VideoPlayer that referenced this pull request May 23, 2020
Dealing with errors within ReactPlayer just caused more bugs
Closes cookpete/react-player#354
Closes cookpete/react-player#355
albanqoku added a commit to albanqoku/react-player that referenced this pull request Feb 24, 2021
Dealing with errors within ReactPlayer just caused more bugs
Closes cookpete/react-player#354
Closes cookpete/react-player#355
Webmaster1116 added a commit to Webmaster1116/video-player that referenced this pull request May 20, 2021
Dealing with errors within ReactPlayer just caused more bugs
Closes cookpete/react-player#354
Closes cookpete/react-player#355
webmiraclepro added a commit to webmiraclepro/video-player that referenced this pull request Sep 9, 2022
Dealing with errors within ReactPlayer just caused more bugs
Closes cookpete/react-player#354
Closes cookpete/react-player#355
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants