It appears that before the <source>
element was introduced for <audio>
tags, when the audio had an error you could see the error code in audio.error.code
. However, this doesn't seem to happen anymore. Since the error events are now only fired on the child <source>
elements and no longer on the audio tag, the audio tag no longer has an error
property (it's always null). The source tags don't get an error property either.
You can see this in this jsFiddle.
How are you suppose to detect the error type now that the audio tag doesn't get an error property? It seems that this is bug in every browser.
It appears that before the <source>
element was introduced for <audio>
tags, when the audio had an error you could see the error code in audio.error.code
. However, this doesn't seem to happen anymore. Since the error events are now only fired on the child <source>
elements and no longer on the audio tag, the audio tag no longer has an error
property (it's always null). The source tags don't get an error property either.
You can see this in this jsFiddle.
How are you suppose to detect the error type now that the audio tag doesn't get an error property? It seems that this is bug in every browser.
Share Improve this question edited Sep 19, 2014 at 20:30 Steven Lambert asked Sep 19, 2014 at 19:10 Steven LambertSteven Lambert 5,9312 gold badges32 silver badges46 bronze badges 3- the error events should still fire... – dandavis Commented Sep 19, 2014 at 19:23
- I see error events on all of your sources (chrome 37.0.2062.120 on mac) – Birgit Martinelle Commented Sep 19, 2014 at 19:25
- 1 the error events still fire, thats not my question. My question is how do you see what the error is (no audio found, no internet connection, etc.) – Steven Lambert Commented Sep 19, 2014 at 19:54
2 Answers
Reset to default 6onerror will fire if you add true after the function.
var audio = document.getElementById('audio');
audio.addEventListener('error', function(e) {
var noSourcesLoaded = (thisworkState===HTMLMediaElement.NETWORK_NO_SOURCE);
if(noSourcesLoaded) console.log("could not load audio source");
}, true);
In Angular you can fire this event to know if aodio did load or not.
this.audio.addEventListener('error', ()=> {
console.log("could not load audio source");
///Do your thing
});