matvp91 / shaka-player-react

A simple React component wrapper for shaka-player
MIT License
110 stars 34 forks source link

Support shaka error events & player load failure. #13

Open matvp91 opened 3 years ago

matvp91 commented 3 years ago

Should add an onError event, which will emit a shaka.util.Error, or a custom error if it's originated from the wrapper implementation. The latter happens when player.load rejects it's promise.

This feature definitely needs a bit of thinking because I'd rather not map each shaka event. We're exposing both shaka's player & ui API through an imperative handle, theoretically this should be suffice for binding any shaka related event.

We do need some sort of error handling when an error occurs due to a method call in the wrapper implementation (such as player.load, but that could confuse people if it was named onError, which is too generic. An onPlayerLoadFailed / onPlayerLoadSuccess event might be better in this case. Those integrating this lib can then use controllerRef.current.player.addEventListener, which is the addEventListener method from the shaka instance underneath.