Pause event is not detected by howler.js when we pause the audio through chrome android notification

834 views Asked by At

I am using howler.js to play audio and declaring instance as

sound = new Howl({
  src: ['../assets/test.mp3'],
  html5: true,
  onpause: () => {
    this.playButton = true;
  }  });

All works fine but when audio is played , chrome android shows notification of song playing, and when we pause audio through notification it is not detected by howler.js.

Please let me know how to detect it in our code.

1

There are 1 answers

3
Kaiido On

Sounds like a bug, I guess you could open an issue on the project's tracker.

For an ugly workaround, you can access the original HTMLAudioElement through

const elem = sound
  ._sounds[0] // OP has only one media
  ._node; // the DOM element

This element will receive the DOM events appropriately, so you can hook on it directly:

elem.addEventListener('pause', () => {
  this.playButton = true;
});