Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use within a PWA context / Service Worker to replicate native audio apps? #232

Open
voxpelli opened this issue Aug 25, 2019 · 7 comments
Open

Comments

@voxpelli
Copy link

voxpelli commented Aug 25, 2019

If one wants to create a Progressive Web App that mimics Spotify or one of the many podcasts apps out there, then currently one needs to have ones app be a Single Page Application, as neither the Media Session API nor the Web Audio API is available in a worker, they all expects the web page context to stay alive.

There is an open issue about making the Web Audio API available to Workers: https://github.com/WebAudio/web-audio-api/issues/1098

And the Media Session API would be the natural UI for such a background playback.

In #48 support for the Web Audio API was added, which meant that as long as https://github.com/WebAudio/web-audio-api/issues/1098 was solved then the Media Session API would likely be available for any AudioContext created within a Service Worker (or other supported Worker)

However, as noted in w3c/audio-session#11, the addition from #48 was dropped in #135 so currently either that direct support for AudioContext would need to be restored for the Media Session API to be a usable interface for interacting with audio playing in workers – or the Media Session API would have to define its own availability within either Service Workers specifically or Workers in general – else it will stay impossible to fully mimic a native audio app as a PWA.

Could it be that the removal was caused by the split of this spec into the Media Session API spec and the Audio Focus API spec (https://github.com/WICG/audio-focus)?

Been asking around on Twitter about this over time, here's link to some of those discussions:

@mounirlamouri
Copy link
Member

Could it be that the removal was caused by the split of this spec into the Media Session API spec and the Audio Focus API spec (https://github.com/WICG/audio-focus)?

Correct.

@NavyCoat
Copy link

@voxpelli is this what you described here will make me able to play two audio streams simultaneously, like for example, Spotify and my podcast PWA?

@voxpelli
Copy link
Author

@NavyCoat Not really, it’s about controlling the playback in the background without relying on a window being open to play it.

A desktop app like Spotify is able to continue play even after you have closed its window, but that is currently not possible for a PWA as it can only do playback from within its HTML page, not from within its background service worker.

@rektide
Copy link

rektide commented Jul 30, 2022

Connecting this to some other issues about,

@voxpelli
Copy link
Author

Linking this issue to whatwg/html#8538 as well

@youennf
Copy link
Contributor

youennf commented Mar 6, 2023

Marking as enhancement for now.

@chrisn
Copy link
Member

chrisn commented Mar 6, 2023

Background playback is definitely an interesting use case for my organization. We'd like to enable media playback that can continue across same-site navigations, and redesigning as a single-page application would be far too costly.

With various proposals being suggested here (service workers, iframes that carry state between navigations, MediaSession for UI, Web Audio support, etc), it seems to me it's worth looking at how to do this holistically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants