muxinc / elements

Custom elements for working with media in the browser that Just Work™
https://elements-demo-nextjs.vercel.app
MIT License
266 stars 49 forks source link

Feature request: mux-video should retry on 412 Not Playable #531

Open par5er opened 1 year ago

par5er commented 1 year ago

<mux-video> will automatically handle recoverable errors that happen during video playback. This is particularly handy for live streams that may experience disconnects.

However, the player does not retry if the video/livestream if Mux sends 412 Not Playable.

Currently I do the following:

videoRef.addEventListener('error', () => {
  setTimeout(() => {
    videoRef.playbackId = 'dummy'
    videoRef.playbackId = actualPlaybackId // artificially trigger reload by changing playbackId
  }, 1000)
})

But it would be helpful to have builtin support for this

dylanjha commented 1 year ago

Thanks for opening @par5er

A 412 error occurs:

In both those scenarios, we don't know when or if the asset will be playable. How long would you expect it to keep retrying for before giving up?

As of today, what we suggest is that in your application you keep track of when an Asset becomes "ready" and when a Live Stream becomes "active". Those are the states when playback should be attempted, and you can get notified via webhooks so that you only initialize the player when the Asset / Live Stream is in a playable state. Are you attempting to play an Asset or Live Stream before it's in one of those states?

ramiel commented 2 months ago

Hello. My two cents on this. My application handles the status change through webhooks. In a way I always thought this is kind of wrong if using your webplayer. I'm expecting it to be notified by you when the livestream is active and automatically retry loading the video.