Some sound issues... 😬

It’s still me, this time it’s about Sound. :sweat_smile:

  • SoundChannel can’t be controlled immediately. For example, the actual effect of the following code is that sound still plays in the background.
    sound.play().stop();
  • The interval duration between repeated sounds is longer.
    sound.play(0, 100);
  • Sometimes the sound is intermittent and the position of SoundChannel instance is inaccurate.

It looks like play().stop() is calling howl.play() then howl.stop() in Howler.js (HTML5 target)

Repeating the sound appears to also call howl.stop() then howl.play() immediately

We also use howl.seek() in order to get the current time

Yes, everything is because of the library of howler.js. :sweat_smile:
Because it has too many unmanaged setTimeout inside, it often causes sound play repeat unexpectedly and the SoundChannel out of control.

The temp solution is to modify:


to

var isplaying = true;
if (self._queue.length > 0)
{
    var last_queue_event = self._queue[self._queue.length - 1].event;
    if (last_queue_event == 'stop' || last_queue_event == 'pause')
    {
        self._queue.splice(0, self._queue.length - 1);
        isplaying = false;
    }
}
if (isplaying)
{
    self._emit('play', sound._id);
}

I think howler.js is not suitable for openfl project at all, it leads to many issues.(Sorry to the author, but it is the truth. :rofl:)

How about rebuilding the Howl class? I am willing to make some contribution for it.

1 Like

Do you recommend another library?

Would it make sense to submit a pull request with fixes to the library instead?

:rofl: Maybe we can rewrite howler.js ?