audio.currentTime 在 IE9 中不起作用
我真的不明白为什么下面的代码似乎在除 IE9 之外的每个浏览器中都有效:
var audio = $("audio.laser").get(0);
if (audio != null && audio.canPlayType) {
audio.pause();
audio.currentTime = 0;
audio.play();
}
奇怪的是,它冻结在“audio.currentTime = 0”,说“currentTime 未定义”。
I really don't see why the following code seems to work in every browser except IE9:
var audio = $("audio.laser").get(0);
if (audio != null && audio.canPlayType) {
audio.pause();
audio.currentTime = 0;
audio.play();
}
Strangely, it freezes at "audio.currentTime = 0", saying "currentTime is undefined".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不遵守标准是网络重罪,而 IE9 则是屡犯者。音频对我来说似乎是只读的。
仅支持此处的内容:
http://msdn.microsoft.com/library/ff975061.aspx
Failure to comply with standards is a web-felony, and IE9 is a repeat offender. Audio looks like it's read-only to me.
Only the things here are supported:
http://msdn.microsoft.com/library/ff975061.aspx
需要尝试的几件事是将:
audio.currentTime = 0;
替换为
audio.currentTime = 0.1;
如果仍然出现相同的错误,您可以尝试将其替换为:
audio.load();
但请注意,load() 不能很好地处理“结束”事件。我不明白其中的原因。
A couple things to try would be to replace:
audio.currentTime = 0;
with
audio.currentTime = 0.1;
If that still gives you same error you could try replacing it with:
audio.load();
But be aware that load() does not play nicely with the "ended" event. The reason for this escapes me.