navigator.getUserMedia在非本地的php服务器上未定义,但是在本地运行良好

时间:2020-07-17 16:38:42

标签: php jquery getusermedia webcam-capture

我正在构建一个允许从网络摄像头捕获和保存照片的平台,在localhost上可以很好地工作,但是将其安装在非本地服务器上时,对我来说不起作用。

    function turnOnCamera(){
     canvas = document.getElementById("resultado");
     cxt = canvas.getContext("2d");
     video = document.getElementById("camara");
    
    if(!navigator.getUserMedia){
         navigator.getUserMedia = navigator.getUserMedia || navigator.webKitGetUserMedia || navigator.                               moxGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;  
    }
    if(!window.ULR){
        window.ULR = window.webkitURL;
    }
    console.log(navigator.getUserMedia);
                     
    if(navigator.getUserMedia){                              
         navigator.getUserMedia({"video":true, "audio":false},
        
            function(stream){
                try{
                        localstream = stream;
                        video.srcObject = stream;
                        video.play();
                }catch(error){
                        video.srcObject = null;
                }
            },function(err){
                console.log("Error :" + err);
            });
    }else{
        console.log("Error :" + "No getUsermedia");
    }
}

控制台响应未定义

0 个答案:

没有答案