允许访问麦克风时,getUserMedia因TrackStartError失败

时间:2014-05-22 12:00:52

标签: javascript google-chrome asp.net-web-api webrtc

我使用的是Chrome版本35.0.1916.114 m

当我使用IIS(例如localhost / test.html)运行我的html页面并点击“允许”到http://localhost/ wants to use your microphone提示时,getUserMedia()失败并出现以下错误:

NavigatorUserMediaError {constraintName:“”,message:“”,name:“TrackStartError”}

代码:

var constraints = {audio: true, video: false};
...
function successCallback(stream) {
...
}

function errorCallback(error){
  console.log("navigator.getUserMedia error: ", error);
}

navigator.getUserMedia(constraints, successCallback, errorCallback);

导致此错误的原因是什么?

1 个答案:

答案 0 :(得分:-3)

var mediaConstraints = {     '强制性' :     {         ' OfferToReceiveAudio' :真的,         ' OfferToReceiveVideo' :假的     } };

在使用约束之前在代码中声明这一点。