Question

I am trying to get an web application running with the webcam video feed and I am not having any luck getting the video feed to the firefox browser. Following is my code.

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!");
}
}   
Était-ce utile?

La solution

After all figured that firefox has decided to change the API and do things a bit differently. I manage to sort out the issue and my code is as follows.

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!");
        }   
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top