In our Chrome App for Chrome OS (yes, we know that Chrome Apps are being discontinued, but this is a kiosk app and kiosk mode is not yet supported for PWAs), we would like to use the chrome.audio API to display system audio volume and mute status. We have audio added to the permissions in our manifest.json, but chrome.audio is returning undefined. Is there something else we need to do to enable the chrome.audio API?
1
votes
Other than a bug in Chrome, without seeing MCVE I can only guess you're not using it in an app script like the background script (e.g. a webview script can't use it) or you didn't reload the app after editing manifest.json and code.
- wOxxOm
That was the issue. Moved it to a background script and it works - thanks!
- Aaron J Spetner
@wOxxOm actually it seems that now it only works in kiosk mode, but when running the app in a user or guest session it still returns chrome.audio as undefined even from the background script. Is this API only supported in kiosk mode?
- Aaron J Spetner
I should add that chrome.permissions.getAll also does not return the "audio" permission when not in kiosk mode (it exists in the manifest.json)
- Aaron J Spetner
Okay according to stackoverflow.com/questions/49884850/… it only works in kiosk mode (of course Google doesn't bother to say that anywhere...)
- Aaron J Spetner
1 Answers
0
votes
The chrome.audio API only works in a background script and only in kiosk mode, not in a content script or in a user/guest session. Moving the call to the background script and running in kiosk mode fixes the issue. It would be nice if Google would bother to document these things...
H/T @wOxxOm