Chrome扩展程序如何获得用户使用用户计算机麦克风的许可? [英] How can a Chrome extension get a user's permission to use user's computer's microphone?

本文介绍了Chrome扩展程序如何获得用户使用用户计算机麦克风的许可?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我们在Chrome的网站上运行以下HTML5的Web Speech API的JavaScript代码,则Chrome会要求用户允许使用用户的计算机麦克风.

If we run HTML5's Web Speech API's JavaScript codes below in a website on a Chrome, Chrome will ask for user's permission for the use of user's computer's microphone.

var recognition = new webkitSpeechRecognition();
recognition.start();

但是,如果我在Chrome扩展程序页面上运行上述代码,则Chrome不会要求用户授予权限. Chrome扩展程序如何获得用户使用用户计算机麦克风的许可?

But if I run codes above on a Chrome extension's page, Chrome doesn't ask users to give a permission. How can a Chrome extension get a user's permission to use user's computer's microphone?

谢谢.

推荐答案

我认为您必须自己实现它.在chrome扩展程序的manifest.json中,有一个权限参数.我认为首先您必须获得在该文件中使用麦克风的许可.我不知道该调用的参数是什么,但是您可以在文档中进行检查.

I think you have to implement it yourself. In chrome extension's manifest.json, there is a permissions parameter. I think first you have to get the permission to use microphone in that file. I don't know what is the parameter called but you can check that in the documentation.

仅当用户安装扩展程序时,才会显示此权限警告.之后,扩展程序可以自动打开/关闭麦克风.要寻求用户的许可,请首先检查正在使用的网站用户,以及是否要激活该网站上的麦克风.之后,只需在该网页中插入HTML/CSS代码即可向用户显示弹出式窗口,以征求她的许可.如果允许,则将消息发送到后台页面,然后将其打开.

This permission warning is shown only when the user installs the extension. After that, the extension can turn microphone on/off at its volition. To seek permission from user, first check which website user is using and if you want to activate the microphone on that. After that, just inject HTML/CSS code in that webpage that will show a popup to user asking for her permission. If the permission is yes, send the message to background page and then just turn it on.

这篇关于Chrome扩展程序如何获得用户使用用户计算机麦克风的许可?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆