admin管理员组文章数量:1331683
SITUATION:
It works fine on Chrome. But there is a small gap every time the "Waterfall 1" sound loops, only on Safari.
WHAT I TRIED SO FAR:
With the HTML 5 audio element:
audio.addEventListener('timeupdate', function(){ var buffer = 0.44; if(this.currentTime > this.duration - buffer){ this.currentTime = 0 this.play() }}, false);
Gapless.js
Howler.js .js
Web Audio API alone: How to seamlessly loop sound with web audio api
QUESTION:
How can I get rid of the gap in the audio loop in Safari ?
SITUATION:
It works fine on Chrome. But there is a small gap every time the "Waterfall 1" sound loops, only on Safari.
WHAT I TRIED SO FAR:
With the HTML 5 audio element:
audio.addEventListener('timeupdate', function(){ var buffer = 0.44; if(this.currentTime > this.duration - buffer){ this.currentTime = 0 this.play() }}, false);
Gapless.js https://github./regosen/Gapless-5
Howler.js https://github./goldfire/howler.js
Web Audio API alone: How to seamlessly loop sound with web audio api
QUESTION:
How can I get rid of the gap in the audio loop in Safari ?
Share Improve this question edited Jul 9, 2021 at 16:17 TheProgrammer asked Aug 14, 2019 at 12:39 TheProgrammerTheProgrammer 1,5094 gold badges30 silver badges54 bronze badges 1- Have you checked stackoverflow./questions/9811429/…? – ranusharao Commented Aug 22, 2019 at 23:29
1 Answer
Reset to default 11 +50I had the same issue and I resolved it by using a file format other than mp3.
I would also highly remend using howler.js!
Here is a detailed article that might help: https://www.kevssite./seamless-audio-looping/
While looking for a fix to this I learnt that part of the ‘pause’ problem is caused by using mp3 as the audio file format. Apparently there is a bug (or maybe its a feature!) in the mp3 spec that adds a few ms of silence at the start of the track. If you load a track into an editor like audacity you can see the gap. You can edit the track to remove the silence, but it’ll be back when you re-load it. I remend using the ogg format instead of mp3 as ogg does not add any silence to the start of the track. Switching to the ogg format certainly made an improvement but there was still a small pause between loops.
Incidentally just converting from mp3 to ogg won’t remove the silence automatically. You’ll need to load the mp3 into an editor, remove the gap from the start of the file, then export the track in the ogg format.
本文标签: javascriptThere is always a gap on my Audio Loop in SafariStack Overflow
版权声明:本文标题:javascript - There is always a gap on my Audio Loop in Safari - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742268960a2443942.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论