howler.js
howler.js copied to clipboard
Delay with html5:true and loop:true
The Problem
When using html5:true and loop:true, there is a pause between repeat with mp3 and wav files. If html5: false - no pause, plays clearly one after another. How to remove pause between repetitions at html5:true?
var sound = new Howl({
preload: true,
src: ['x1.wav'],
loop: true,
html5: true,
onloaderror(id, err) {
console.log(id, err)
},
onplayerror: function(e) {
console.log(e)
},
onload() {
document.getElementById('loading').style.display = 'none'
},
});
document.getElementById('start').addEventListener("click", () => {
sound.play();
})
Reproducible Example
No response
Reproduction Steps
Set options: loop: true, html5: true,
Possible Solution
No response
Context
No response
Howler.js Version
2.2.3
Affected Browser(s)/Versiuon(s)
chrome
Have the same problem, also with ogg files
Same problem 2.2.2 and 2.2.3 with mp3 files. Setting html5 to false still produces the issue
Happens in both chrome and safari on iPhone 14 pro max
I have small files,loop its, it work with no delay but you would selcects buffer
const soundPlayed = new Howl({
autoplay: false,
loop: false,
preload: true,
html5: true,
onplay: function () {
soundPlayed._sounds[0]._node.addEventListener(
'timeupdate',
function () {
let buffer = 0.46
if (this.currentTime > this.duration - buffer) {
console.warn('timeupdate');
this.currentTime = 0;
}
},
false,
);
},
});
I have this issue but only on iOS device
Same issue with .m4a on iOS only. I have a 52 second audio file that would play once aloud, then once silently, then repeat.
Solution from @beocaca worked well by basically turning off the loop and reseting the track time to 0 when the track is almost finished.
I had to setup my code to specifically run the fake looping block only for iOS.
Typical iOS frustrations...