I m使用以下代码试图用超文本5录音带播放录音带:
HTMLAudioElement.prototype.playClip = function(startTime, stopTime) {
this.stopTime = stopTime;
this.currentTime = startTime;
this.play();
$(this).bind( timeupdate , function(){
if (this.ended || this.currentTime >= stopTime) {
this.pause();
$(this).unbind( timeupdate );
}
});
}
I utilize this new playClip
method as follows. First I have a link with some data
attributes:
<a href=# data-stop=1.051 data-start=0.000>And then I was thinking,</a>
最后,这一节奏在<代码>下运行(文件)。
$( a ).click(function(ev){
var start = $(this).data( start ),
stop = $(this).data( stop ),
audio = $( audio ).get(0),
$audio = $(audio);
ev.preventDefault();
audio.playClip(start,stop);
})
这种做法似乎奏效,但令人沮丧的是:有时,某一个剪辑的反馈超出了正确的<代码>数据-终点代码>。
我怀疑,它可能与<代码>日间更新代码>活动的时间有关,但我不知道如何开始解决这个问题。 在这里,我聚集了几个小lu:
- The same behavior appears to come up in both FF and Chrome.
- The playback of a given clip actually seems to vary a bit -- if I play the same clip a couple times in a row, it may over-play a different amount of time on each playing.
这里的问题是否是音频预报工具的固有准确性? 我的 app需要一流。
Is there a problem with the way I m using jQuery to bind and unbind the timeupdate
event? I tried using the jQuery-less approach with addEventListener
but I couldn t get it to work.
事先感谢,我真心要知道什么是错的。