Catching HTML5 media network error javascript -


is there anyway can catch network error in case try create new audio() object , src url not resolved? try/catch doesn't work here apparently.

you have docs here: docs

and info you:

<p id="player">non existing media file - click play</p>  <audio preload="none" controls>     <source id="wav" src="http://yourpage.com/false.wav" />     <source id="mp3" src="http://yourpage.com/false.mp3" /> </audio> 

and simple use js:

$("#player").on("click", function () {     alert("trying play file.");     try {         $('audio')[0].play();     } catch (e) {         alert("error playing file!");     } }); $("audio").on("error", function (eevent) {         alert("error @ audio tag!");     }); $("#wav").on("error", function (event) {         alert("no wav file!");     }); $("#mp3").on("error", function (event) {         alert("no mp3 file!");     }); 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -