Making an extension that plays audio even when the extension is closed

1,005 views
Skip to first unread message

Larrie

unread,
Sep 7, 2022, 10:02:30 AM9/7/22
to Chromium Extensions

I'm making a simple extension that loads an HTML file as the default popup.

In the HTML file I have an <audio> element.

In the <audio> element I am linking to a javascript file that loads a .pls file.

When I open the extension the audio plays fine, but when I close the extension or switch tabs the audio stops playing.

Is there a way so when I close the extension or switch tabs the audio will keep playing?

Is it even possible to have popup.html playing audio when the extension is closed?

popup.html
html.png

manifest.json
json.png

I tried adding audio-player.js as a background service worker in my manifest.json file and I also tried adding popup.html as a background service worker:

carbon-1.png

And

carbon-2.png

But the audio stops playing when I close the extension.

Any help much appreciated.

Thanks.

Link to the audio-player.js code:

https://goonlinetools.com/snapshot/code/#zoc24nogygr9ed25cj2ag

wOxxOm

unread,
Sep 7, 2022, 10:38:44 AM9/7/22
to Chromium Extensions, Larrie
There's no sensible solution in ManifestV3 until chrome.offscreen is implemented in stable Chrome, currently it's still in development/Canary channel. Either use a ManifestV2 extension for now or open a new small window which will play the audio (you can open it in a minimized state).
Message has been deleted

Larrie

unread,
Sep 8, 2022, 6:21:17 AM9/8/22
to Chromium Extensions, wOxxOm, Larrie
OK thanks for your reply :)
Reply all
Reply to author
Forward
0 new messages