Open skogsmaskin opened 5 years ago
I also thought of this, not a fan of the predefined error that can come up anytime and mess up the design in somewhat unexpected and scarcely controllable way.
I am currently dealing with this exact issue. Have been getting a levelLoadTimeout
network error a few times today, which causes the component to display the error message instead of a video. An onError
prop is a good idea, but maybe too vague and generic? If you look at this error message I got in the console, you can see that timeout
is hardcoded to an arbitrary 10000 ms, and maxRetry
is set to 0. Maybe if you could have those values as defaults, and then you can override them with props? Along with retryDelay
, maxRetryDelay
, etc. Or are these config values outside of your control maybe?
The player obviously need some kind of internal error handling as some errors are fatal and other's not. The
Hls.ErrorTypes.MEDIA_ERROR
for instance are not displayed, as they are non-fatal. Errors likeHls.ErrorTypes.NETWORK_ERROR
are obviously fatal and should be notified to the user. For now we just hide the video and display that error inside the component.I don't like the fact that we actually display those fatal errors inside the player as developers most certainly would like to have some control over how they are displayed and which wording they have.
I'm thinking it would be better to facilitate for a
onError
prop where the developer can deal with the errors and how to display them their selves. One could of course have a fallback too to a default error display inside the component if theonError
prop is undefined.Another thing is that the errors can vary depending on if HLS.js is used, or the system support HLS natively (iOS for instance). So maybe some kind of error abstraction would be nice too.