HTML音频不能设置currentTime的 [英] HTML audio can't set currentTime
本文介绍了HTML音频不能设置currentTime的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Chrome。在我的开发工具的控制台,我尝试了以下内容:
I am using Chrome. In my dev tools console, I tried the following:
一切正常,除了最后一道防线。为什么我不能设置 currentTime的
就可以了?
Everything works as expected except last line. Why can't I set currentTime
on it?
此外,在一般情况下,我发现这整个HTML5音频的东西不是很可靠。是否有fallsback闪烁强大的JavaScript包装?
Also in general, I am finding this whole HTML5 Audio thing to not be very reliable. Is there a robust javascript wrapper that fallsback to flash ?
推荐答案
您需要做这样的事情(如果你使用jQuery)
You need to do something like this (if you use jQuery)
$('#elem_audio').bind('canplay', function() {
this.currentTime = 10;
});
或在Javascript
or in Javascript
var aud = document.getElementById("elem_audio");
aud.oncanplay = function() {
aud.currentTime = 10;
};
该设置背后的原因是,你需要确保在音频准备播放即可。
这篇关于HTML音频不能设置currentTime的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文