我使用的是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);
导致此错误的原因是什么?
答案 0 :(得分:-3)
var mediaConstraints = { '强制性' : { ' OfferToReceiveAudio' :真的, ' OfferToReceiveVideo' :假的 } };
在使用约束之前在代码中声明这一点。