我正在尝试在 Chrome 中使用 navigator.getUserMedia ;但是,它在本地提供时不会请求权限(file:///whatever/index.html),但在 JSFiddle 上会请求权限(http://jsfiddle.net/EBsvq/ http://jsfiddle.net/EBsvq/)和其他网站。
有谁知道这是为什么?我需要以某种方式重置我的权限吗?
这是我在本地使用的:
<html>
<head></head>
<body>
<button id="btn">Start</button>
<script type="text/javascript">
/*! jQuery v1.8.3 jquery.com | jquery.org/license */
//JQuery goes here
</script>
<script type="text/javascript">
navigator.getUserMedia = navigator.webkitGetUserMedia || navigator.getUserMedia;
$(function(){
$('#btn').click(function(){
navigator.getUserMedia({audio: true},
function(){
alert('success');
},
function (err) {
alert('fail: ' + JSON.stringify(err));
}); }); });
</script>
</body>
</html>
Chrome 屏蔽了很多内容file:///
不报告安全错误的 URI(例如地理定位 https://stackoverflow.com/q/5423938/8655)。你最好的选择是从本地网络服务器运行,如果你安装了Python,请尝试简单HTTP服务器 http://www.linuxjournal.com/content/tech-tip-really-simple-http-server-python.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)