网络音频API:完美的循环如何 [英] Web audio API : perfect looping how to
本文介绍了网络音频API:完美的循环如何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在播放的文件为一个循环,还有一个音频空白结束和开始的。
我怎样才能避免这种情况?为得到一个连续的声音。谢谢
When playing file as a loop, there is still an "audio blank" between end and start. How can I avoid this ? For getting a continuous sound. thanks
推荐答案
https://jsfiddle.net/0xkt1uto / 1 /
在第一> 98%完成,第二次将启动。
When the first is >98% complete, the second will start.
在第二个是98%完成后,将首先启动。
When the second is >98% complete, the first will start.
当他们过来,他们将重置为0,准备下一次的发挥。
When they are over, they will reset to 0, ready for the next play.
在code:
<audio id="aud1" controls>
<source src="http://www.noiseaddicts.com/samples_1w72b820/4205.mp3" type="audio/ogg">
</audio>
<audio id="aud2" controls>
<source src="http://www.noiseaddicts.com/samples_1w72b820/4205.mp3" type="audio/ogg">
</audio>
JS&安培; jQuery的
var aud1 = $('#aud1').get(0);
var aud2 = $('#aud2').get(0);
aud1.play();
$(aud1).on('timeupdate', function(){
if((this.currentTime/this.duration)*100 > 98){
aud2.play();
}
});
$(aud2).on('timeupdate', function(){
if((this.currentTime/this.duration)*100 > 98){
aud1.play();
}
});
$(aud1).on('ended', function(){
this.currentTime = 0;
});
$(aud2).on('ended', function(){
this.currentTime = 0;
});
这篇关于网络音频API:完美的循环如何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文