Html5 audio / jQuery:播放延迟问题(预加载) [英] Html5 audio / jQuery : playback latency issue (preload)
问题描述
我正在使用html5音频并遇到缓冲区的一些麻烦。这在Chrome中非常出色,但在Safari(和SafMob)中有明显的延迟。这个想法很简单。用户单击img链接并且img跳转并发出声音。 以下是一个示例。
I am working with html5 audio and running into some troubles with the buffer. This works splendidly in Chrome, however in Safari (and SafMob) there is noticeable latency. The idea is simple. A user clicks an img link and the img "jumps" and makes a sound. Here is an example.
有没有办法预加载声音文件,以便更快地播放?同样,我主要关心的是Safari / Safari Mobile浏览器。
Is there a way to preload the sound file so that it plays quicker? Again, my main concern is in the Safari/Safari Mobile browser.
我正在使用的jQuery:
The jQuery I am using:
$("#bell a").click(function() {
var snd = new Audio("ping.mp3");
snd.play();
$(this).stop().animate({ marginTop: "-10px" }, 200).animate({ marginTop: "18px" }, 200).animate({ marginTop: "1px" }, 300);
return false;
});
这是按钮的代码:
<ul id="bell">
<li class="button"><a href="#" title="Pling">Link Text</a></li>
</ul>
推荐答案
preload实际上需要一个值,auto,meta之一或自动的。虽然我认为默认行为是下载整个文件。
preload actually takes a value, one of auto, meta or automatic. Although I think the default behaviour is to download the entire file.
There's a bit more at: Playing with audio files or from the specification itself: preload attribute.
不确定是否这样完全有帮助。
Not sure if this helps at all.
这篇关于Html5 audio / jQuery:播放延迟问题(预加载)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!