howler.js icon indicating copy to clipboard operation
howler.js copied to clipboard

Delay with html5:true and loop:true

Open SY-art opened this issue 2 years ago • 5 comments

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

SY-art avatar Mar 11 '22 19:03 SY-art

Have the same problem, also with ogg files

deathvulture avatar Jan 14 '23 12:01 deathvulture

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

voporak5 avatar Mar 07 '23 20:03 voporak5

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,
            );
          },
        });

beocaca avatar Mar 22 '23 08:03 beocaca

I have this issue but only on iOS device

jmaldon1 avatar Sep 21 '23 12:09 jmaldon1

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

rhydianpala avatar Nov 17 '23 23:11 rhydianpala