Hello,
I am in the process of converting a WebExtension to a Safari Extension. The point of it is to play a radio live mp3 by clicking on a button in the extension browser action/popup.
My audio object is created in the background page, and stopped when the user returns in the browser action/popup.
It works totally fine on Chrome, Firefox and Edge.
But in Safari, the audio never starts.
I construct it this way:
Here is a sample of the manifest.json file:
When I open the URL in a Safari tab, it works fine.
So I suspect there are some kind of permissions, or special thing to do in order to run audio in the background?
I browsed the various XCode menus (which I'm not familiar to), and did not find any "Capability"/"Background" stuff to enable audio playback for Extension background page.
Any idea? Any pointers?
Thank you very much :-)
I am in the process of converting a WebExtension to a Safari Extension. The point of it is to play a radio live mp3 by clicking on a button in the extension browser action/popup.
My audio object is created in the background page, and stopped when the user returns in the browser action/popup.
It works totally fine on Chrome, Firefox and Edge.
But in Safari, the audio never starts.
I construct it this way:
Code Block javascript //background.js const audio = new Audio() audio.src = 'https://url/to/live.mp3' audio.volume = 1 audio.type = 'audio/mpeg' browser.runtime.onConnect.addListener(port => { port.onMessage.addListener(message => { if (message.action === 'play') { audio.load() audio.play() } // ... and other stuff to handle the playback with UI driven actions }) })
Here is a sample of the manifest.json file:
Code Block json { "name": "MSG_extension_name", "version": "1.6.0", "description": "MSG_extension_description", "manifest_version": 2, "default_locale": "fr", "background": { "scripts": [ "background.js" ], "persistent": true } }
When I open the URL in a Safari tab, it works fine.
So I suspect there are some kind of permissions, or special thing to do in order to run audio in the background?
I browsed the various XCode menus (which I'm not familiar to), and did not find any "Capability"/"Background" stuff to enable audio playback for Extension background page.
Any idea? Any pointers?
Thank you very much :-)