Can service worker access camera or microphone?

549 views
Skip to first unread message

Lu Xu

unread,
Sep 17, 2021, 5:16:44 PM9/17/21
to chromium-...@chromium.org
Hi,
My extension would like to access the camera or microphone, I suppose one way is to open an extension page and access them on that tab and keep it open.
My question is can the extension background script or service worker also access them? Then extension can work in the background.
Thank you very much

wOxxOm

unread,
Sep 18, 2021, 2:28:16 AM9/18/21
to Chromium Extensions, thus...@gmail.com
  • Service workers don't have navigator.mediaDevices.getUserMedia as you can see by inspecting navigator object in devtools console of a service worker. 
  • MV2 background scripts couldn't use this API as well, see https://crbug.com/160337 (it mentions the old prefixed names but otherwise is still relevant).

Now that Manifest V3 has shipped and changed the available APIs for an extension from "Window" to "Worker" APIs, this is an appropriate topic for standardization work rather than implementation work: Should GetUserMedia be available on Worker?

So far, the response of the standards community has been a resounding "No" because all the concepts around prompting, displaying in-use indicators and so on have been strongly tied to the page context (tab) and its origin.

If you want this topic revisited, joining the W3C WEBRTC WG and arguing for it might be a good idea.

Lu Xu

unread,
Sep 18, 2021, 12:33:34 PM9/18/21
to wOxxOm, Chromium Extensions
Makes sense, thank you wOxxOm for the details!
Reply all
Reply to author
Forward
0 new messages