admin 管理员组文章数量: 1086019
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
});
本文标签: javascriptHow to detect error type for Audio tag with SourcesStack Overflow
版权声明:本文标题:javascript - How to detect error type for Audio tag with Sources - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744004458a2517034.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论