navigator.mozGetUserMedia does not call onvideosuccess method

1.5k views Asked by At

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!");
}
}   
1

There are 1 answers

0
Tharanga On BEST ANSWER

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!");
        }