简体   繁体   English

如何在Chrome OS或Chrome扩展程序的打包应用程序中启用相机和麦克风?

[英]How to enable camera and microphone in packaged application for Chrome OS or Chrome extension?

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" . 我已将权限包含在"audioCapture""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);
            });    

If you need to provide audio/video for a <webview> -embedded page, requiring "audioCapture" / "videoCapture" permissions is not enough. 如果您需要为<webview> "audioCapture"页面提供音频/视频,则需要"audioCapture" / "videoCapture"权限是不够的。

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. 在普通的Chrome中,您会看到一个允许用户允许/拒绝请求的信息栏。

<webview> does not show those elements, instead it raises an event and it's up to the app to allow/deny it: <webview>不显示这些元素,而是引发一个事件 ,由应用程序决定是否允许/拒绝它:

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. 以下示例代码将授予访客页面对webkitGetUserMedia API的访问权限。 Note that an app using this example code must itself specify audioCapture and/or videoCapture manifest permissions: 请注意,使用此示例代码的应用程序必须自己指定audioCapture和/或videoCapture清单权限:

 webview.addEventListener('permissionrequest', function(e) { if (e.permission === 'media') { e.request.allow(); } }); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM