小编med*_*edo的帖子

navigator.mediaDevices.getUserMedia 与 http 服务器

我怎样才能navigator.mediaDevices.getUserMedia在http服务器上为所有浏览器工作。这可能吗?如何实现?

这是我的代码,不适用于 http,但适用于 https 服务器

navigator.mediaDevices.getUserMedia({ video: true, audio: false })
         .then(function(stream) {
             video.srcObject = stream;
             video.play();
            })
         .catch(function(err) {
            console.log("An error occurred! " + err);
            });

  video = document.getElementById('video');
  video.addEventListener('canplay', function(ev){
  if (!streaming) {
    
    height = video.videoHeight / (video.videoWidth/width);
  
    video.setAttribute('width', width);
    video.setAttribute('height', height);
    canvas.setAttribute('width', width);
    canvas.setAttribute('height', height);
    streaming = true;
  }
}, false);
Run Code Online (Sandbox Code Playgroud)

javascript

4
推荐指数
1
解决办法
7177
查看次数

标签 统计

javascript ×1