Skip to content

Audio position resets when using (mobile) notification controls, Media Session API vs .play()/.pause().Β #1262

@bikubi

Description

@bikubi

Or, more generally, does Howler handle mobile OS audio controls?

On mobile devices, when you play HTML5 Audio, the OS let's you control it. (Android: notification drawer, per-app + headset remote control, somewhat globally; iOS: "Control Center", globally).
My web app has regular (browser) control buttons, too. Both control schemes (let's call them "OS" and "browser") should work seamlessly & interchangeably, IMO. But, they only work as long as i stick to one scheme exclusively (pause/unpause by browser, pause/unpause by OS) - as soon as I mix (play by browser, pause by OS, unpause by browser), the audio position is reset to zero.
As far as I can tell, this happens somewhere in play(), but I could not pin it down exactly.

I have made a Pen to reproduce the issue, with instructions. Tested on Android 9 / Chrome 78.
Note that this does not occur on the Music Player example, where you have to essentially pause twice (play by browser, pause by OS, pause again by browser, then play by browser).

Background:

  • the Android/Chrome notification controls fire play and pause events on the Audio node, but just by looking at the event AFAIK there is no way to tell that they came "from the OS"
  • This is all, of course, pre Media Session API

Any insight welcome!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions