How to handle Media Errors with Hls.js

1.3k Views Asked by At

I have been playing a bit with hls.js, there is a part not clear for me. Supposing a media error event is emitted (Hls.ErrorTypes.MEDIA_ERROR), I know that hls.js will try to recover from it. However, it might fail to do so.

I call the recoverMediaError() function which basically detaches and reattaches the video.

My question is: if this fails (detach will not, can attach fail..?), will hls.js emit a new error event..? I have been trying to simulate this during development, however I cannot find a way to create such a behavior in a custom way (e.g. setting a buffer initial value to 0 or something like that).

It would be great if there was a way to simulate the bufferstalled error case, however I have not found a way to do so.

my case is similar to the one described here (however this is a very old post) hls.js - how to subscribe to any event

I tried to set some initial values capLevelToPlayerSize: true, maxBufferLength: 1000, backBufferLength: 0, maxLoadingDelay: 0.1

however this did not really help to simulate the bufferstalled case. Tried also some cpu throttling, did not help.

I checked that if I emit custom error events (e.g. upon attaching from a recoverMediaError attempt), code will behave as expected, however if this does not happen as the default library behavior (error emit if recoverMediaError results in another error), I might face unexpected behavior.

0

There are 0 best solutions below