Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 video error handling

I need to tell, whether video cannot be played ("x" sign is shown in browser).

This code does't works. "onerror" event will never be fired under Firefox

var v = document.getElementsByTagName("video")[0];     if ( v != undefined )         v.onerror = function(e) {             if ( v.networkState == v.NETWORK_NO_SOURCE )             {                 // handle error             }         } 

What's wrong here ?

like image 995
AntonAL Avatar asked Apr 06 '11 21:04

AntonAL


People also ask

Why does my browser not support HTML5 video?

If your browser error "HTML5 video file not found", it means that your browser is not up to date or website pages does not have a suitable video codec. It would help if you communicated with the developer to solve the issue and install all the required codecs.

Why is video not working on HTML?

There are 3 things to check: make sure your video files are properly encoded for web delivery. make sure the server where the videos are hosted is properly configured for web delivery. make sure your others scripts on the page do not interfere with video playback.

What does HTML5 video file not found mean?

If you come across an HTML5 page with the following error message “file not found,” then it means your browser doesn't have the proper video codec installed. For example, if you are using Google Chrome and you come across an HTML5 MP4 video, then you may get an error message because you don't have an MP4 codec.


Video Answer


1 Answers

"onerror" is not a valid event type for <video>

Use "error" instead.

document.getElementsByTagName('video')[0].addEventListener('error', function(event) { ... }, true); 

For a complete list of events for <video> go here: https://developer.mozilla.org/En/Using_audio_and_video_in_Firefox

like image 131
therealklanni Avatar answered Sep 24 '22 21:09

therealklanni