English 中文(简体)
默哀5
原标题:Timing issues with playback of the HTML5 Audio API

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.

事先感谢,我真心要知道什么是错的。

最佳回答

<代码> 时间范围 活动只发生三至四倍的第二次火灾,没有接近微秒的准确度。 然后,它比<条码>准时>>>>>>>>>>>>>>>>>>>>>>>> >Interval更佳,如果该表不活跃于google chrome(音频文档聆听,则每秒发生一次火灾。

但是,如果在你看来可以确保表格在聆听时活跃,那么setoutset Interval<>code/code>就好了,因为它可以每秒100次发射。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.