javascript - There is always a gap on my Audio Loop in Safari - Stack Overflow

SITUATION:It works fine on Chrome. But there is a small gap every time the "Waterfall 1" sou

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:

  1. 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);

  2. Gapless.js

  3. Howler.js .js

  4. 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:

  1. 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);

  2. Gapless.js https://github./regosen/Gapless-5

  3. Howler.js https://github./goldfire/howler.js

  4. 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
Add a ment  | 

1 Answer 1

Reset to default 11 +50

I 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742268961a4412336.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信