最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to enable camera and microphone in packaged application for Chrome OS or Chrome extension? - Stack Overflow

programmeradmin5浏览0评论

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);
            });    

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);
            });    
Share Improve this question edited Jan 22, 2015 at 14:39 Jacek asked Jan 22, 2015 at 12:57 JacekJacek 711 silver badge4 bronze badges 6
  • You are embedding Hangouts in a <webview>, correct? – Xan Commented Jan 22, 2015 at 13:01
  • Yes, exactly like you said. – Jacek Commented Jan 22, 2015 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 Commented Jan 22, 2015 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 Commented Jan 22, 2015 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 Commented Jan 22, 2015 at 15:08
 |  Show 1 more ment

1 Answer 1

Reset to default 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();
  }
});

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论