【发布时间】:2014-03-02 02:03:35
【问题描述】:
sounds["foo"]= new Audio("foo.ogg");
function playSound(id){
var snd = this.sounds[id];
if(snd.currentTime>snd.duration*0.99999){
snd.pause();
snd.currentTime=0;
//snd.seekable.start(); //doesnt work
//snd.load(); does the trick but with the cost re-downloading the clip every single time
snd.play();
}
if(snd.currentTime==0)
snd.play();
}
出于某种原因 playSound('foo');第一次工作,但在 Chrome 上失败(在 Firefox 上工作得很好)。添加 snd.load() 似乎可以解决此问题,但现在每次播放剪辑时它都会从服务器下载剪辑,这在我的用例中很多。
编辑:哦,snd.currentTime 似乎最后卡住了,所以 snd.currentTime=0 什么都不做。
【问题讨论】:
标签: javascript html google-chrome audio