我正在尝试使用网络摄像头视频源运行Web应用程序,我没有运气到Firefox浏览器的视频。以下是我的代码。
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
if(this.videoelement){
if(this.browser.hasVideoCameraSupport())
navigator.getUserMedia({video: true, audio: true},
function(stream) {
this.videoelement.src = window.URL.createObjectURL(stream);
this.videoStream = stream;
this.videoRunning = true;
if (typeof callback === "function")
callback(this.videoStream);
}.bind(this) ,
function (err) {
alert("Unknown Error "+err.message);
}
);
} else{
alert("You HTML dom Does have a video element!");
}
}
答案 0 :(得分:0)
毕竟认为firefox决定改变API并做一些不同的事情。我设法解决了这个问题,我的代码如下。
var videoelement = document.querySelector('video');
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
if(videoelement){
navigator.getUserMedia({video: true, audio: false},
function(stream) {
if (navigator.mozGetUserMedia) {
videoelement.mozSrcObject = stream;
} else {
var vendorURL = window.URL || window.webkitURL;
videoelement.src = vendorURL.createObjectURL(stream);
}
videoelement.play();
}.bind(this) , function (err) {
alert("Unknown Error "+err.message);
});
} else{
alert("You HTML dom Does have a video element!");
}