I currently use following, but event reveals little about error.
const video = document.getElementById("video")
const source = video.getAttribute("data-source")
video.src = source;
video.addEventListener("error", (event) => {
console.log("BOOM")
})
"...But
eventreveals little about error."
Well you did put console.log("BOOM") as the response. It was never gonna be informative.
You want to detect Error type of either: MEDIA_ERR_NETWORK or MEDIA_ERR_SRC_NOT_SUPPORTED.
Try something like this:
video.addEventListener("error", (event) => { handle_Media_Errors (event) } );
function handle_Media_Errors (evt)
{
//# code credits: https://gist.github.com/wilmoore/3252894
//# video playback failed - show a message saying why...
switch (evt.target.error.code)
{
case evt.target.error.MEDIA_ERR_DECODE:
console.log('Media Error ::: The video could not be decoded.');
break;
case evt.target.error.MEDIA_ERR_ABORTED:
console.log('Media Error ::: video playback was aborted.');
break;
case evt.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED:
console.log('Media Error ::: The video could not be loaded or its format is not supported.');
break;
case evt.target.error.MEDIA_ERR_NETWORK:
console.log('Media Error ::: Video download failed due to a network error');
break;
default:
console.log('Media Error ::: An unknown error with your media file has occurred.');
break;
}
}