当我点击“允许”时,为什么getUserMedia会抛出[对象NavigatorUserMediaError]在Chrome? [英] Why is getUserMedia throwing a [object NavigatorUserMediaError] when I click "Allow" in Chrome?

查看:608
本文介绍了当我点击“允许”时,为什么getUserMedia会抛出[对象NavigatorUserMediaError]在Chrome?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我在尝试通过我的网站访问客户端的麦克风时遇到了错误。当Chrome询问是否允许该网站访问用户的麦克风时,无论是单击允许还是拒绝,都会生成 [object NavigatorUserMediaError] 。无论麦克风是否实际插入计算机(运行Ubuntu 12.04),都会发生这种情况。



通过Firefox进行的进一步测试表明,这不是特定的到Chrome。问题才在我完成实时输入演示然后退出计算机后才开始。我尝试制作一个访问麦克风的裸机演示,但遇到了同样的问题。

  var getVideo = false,getAudio =真; 

navigator.getUserMedia || (navigator.getUserMedia = navigator.mozGetUserMedia ||
navigator.webkitGetUserMedia || navigator.msGetUserMedia);

函数init(){
if(navigator.getUserMedia){
navigator.getUserMedia({video:getVideo,audio:getAudio},onSuccess,onError);
} else {
alert('getUserMedia failed。');
}
}

函数onSuccess(){
console.log(Yay);
}

函数onError(错误){
console.log(Noo+ err);
}

这是令人费解的,因为它一直工作到我记录的地步out然后重新登录并尝试再次测试它。



我通过Jetty和Eclipse在本地托管Web代码。我通过在网络浏览器中输入 localhost:8080 / my-program 来访问它。



编辑:
发生错误后,相机的图标会显示在Chrome地址栏中,表示Chrome正在访问我的麦克风并列出两个可能的麦克风,默认和内置音频模拟立体声。



编辑2:
在尝试通过webrtc访问我的麦克风的其他网站上也会出现此错误。传统的Flash实现仍然有效。



Chrome似乎在打开时定期抛出错误消息。

  [361:362:0725/095320:错误:audio_output_device.cc(186)] 
未实现在virtual void
media :: AudioOutputDevice :: OnStateChanged( media :: AudioOutputIPCDelegate :: State)

编辑3:
我能够澄清错误信息多一点

  NavigatorUserMediaError {code:1,PERMISSION_DENIED:1} 


解决方案

**一次一个浏览器**



<当我打开多个浏览器进行测试时,我遇到过这种情况。似乎一次只能有一个浏览器访问媒体。



即当我在Chrome中打开我的页面,并且视频/音频工作正常时,那么Firefox将无法运行,当我在Firefox中运行时,Chrome就无法运行。


Recently, I started getting errors when trying to access the client's mic through my website. When Chrome asks whether to allow the site to access the user's microphone, [object NavigatorUserMediaError] is produced whether they click "allow" or "deny." This has been happening regardless of whether or not a microphone is actually plugged into the computer (which is running Ubuntu 12.04).

Further testing through Firefox showed that this is not specific to Chrome. The problem only started after I had done a live-input demo and then logged out of the computer. I tried making a bare bones demo of accessing the microphone, and it ran into the same problem.

var getVideo = false, getAudio = true;

navigator.getUserMedia || (navigator.getUserMedia = navigator.mozGetUserMedia ||
        navigator.webkitGetUserMedia || navigator.msGetUserMedia);

function init() {
    if(navigator.getUserMedia) {
        navigator.getUserMedia({video:getVideo, audio:getAudio}, onSuccess, onError);
    } else {
        alert('getUserMedia failed.');
    }
}

function onSuccess() {
    console.log("Yay");
}

function onError(err) {
    console.log("Noo " + err);
}

This is rather puzzling as it had worked perfectly up until the point where I logged out and then logged back in and tried to test it again.

I am hosting the web code locally, through Jetty and Eclipse. I am accessing it by typing localhost:8080/my-program into the web browser.

Edit: After the error occurs, the icon of a camera shows up in the chrome address bar, saying that Chrome is accessing my microphone and listing two possible microphones, "Default" and "Built-in Audio Analog Stereo."

Edit 2: This error is also occurring on other websites that try to access my microphone through webrtc. Traditional Flash implementation still works.

Chrome seems to be throwing out an error message at regular intervals while open.

[361:362:0725/095320:ERROR:audio_output_device.cc(186)] 
Not implemented reached in virtual void
media::AudioOutputDevice::OnStateChanged(media::AudioOutputIPCDelegate::State)

Edit 3: I was able to clarify the error message a bit more

NavigatorUserMediaError {code: 1, PERMISSION_DENIED: 1}

解决方案

** One Browser at a Time **

I've encountered this situation when I am testing with multiple browsers open. It would appear that only one browser can access the media at a time.

ie When I've got my page open in Chrome, and the video/audio is working, then Firefox won't work, and when I've got it working in Firefox, then Chrome doesn't work.

这篇关于当我点击“允许”时,为什么getUserMedia会抛出[对象NavigatorUserMediaError]在Chrome?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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