3

I'm testing scenario where I call a hangouts web page in separate window but application doesn't have access to microphone and camera - buttons are red and message says that "Hangouts can't use the selected microphone/camera".

I have included in permissions "audioCapture" and "videoCapture".

What has to be done to make it work?

Edit:

After allowing media app has access to camera and microphone - I can see that in settings of hangouts but picture and voice are not transmitted over the hangouts to other participants. Is there something I have to set for streaming media?

I already have this piece of code:

navigator.webkitGetUserMedia({ audio: true, video: true },
            function (stream) {
                mediaStream = stream;
            },
            function (error) {
                console.error("Error trying to get the stream:: " + error.message);
            });    
Jacek
  • 71
  • 1
  • 4
  • You are embedding Hangouts in a ``, correct? – Xan Jan 22 '15 at 13:01
  • Yes, exactly like you said. – Jacek Jan 22 '15 at 14:16
  • Maybe you are opening the stream for the app itself, and the embedded page can't get it because it's exclusive access? – Xan Jan 22 '15 at 14:45
  • I don't quite inderstand (I'm new at packaged apps). I can say that as a Chrome extension it works but as a packaged app on Chrome OS media are not transmitted. – Jacek Jan 22 '15 at 14:51
  • My point is, this code should NOT be in your app; Hangouts should request `GetUserMedia` itself, you only need to take care of that permission request. If this code is in your app, it may be conflicting with Hangouts. – Xan Jan 22 '15 at 15:08
  • I uderstand. Is it still applicable if the same app works as a Chrome Extension but opens in separate window (chrome.app.window.create)? – Jacek Jan 23 '15 at 07:57

1 Answers1

5

If you need to provide audio/video for a <webview>-embedded page, requiring "audioCapture"/"videoCapture" permissions is not enough.

To use those, the page requests permission to the browser. In normal Chrome you'll see an infobar allowing the user to allow/deny the request.

<webview> does not show those elements, instead it raises an event and it's up to the app to allow/deny it:

permissionrequest

Fired when the guest page needs to request special permission from the embedder.

The following example code will grant the guest page access to the webkitGetUserMedia API. Note that an app using this example code must itself specify audioCapture and/or videoCapture manifest permissions:

webview.addEventListener('permissionrequest', function(e) {
  if (e.permission === 'media') {
    e.request.allow();
  }
});
Xan
  • 74,770
  • 16
  • 179
  • 206
  • 1
    I am developing a Chromebook kiosk app that needed access to the microphone and camera; this snippet plus the `audioCapture` and `videoCapture` permissions in `manifest.json` worked perfectly. – Joe Oct 27 '16 at 13:28
  • 1
    For a chrome extension, you can't add the videoCapture permission it seems. – user239558 Oct 24 '18 at 10:40