iOS 11的getUserMedia不工作?

苹果公司发布了一个声明,即在iOS 11上getUserMedia将完全正常运行。安装iOS 11 Beta版本5后,我得到一个消息,说明我的网站请求访问我的相机和麦克风,但似乎这条线:

 video.src = window.URL.createObjectURL(stream); 

要么:

 video.srcObject = stream; 

不起作用。 没有错误,没有例外,从手机的相机根本没有图片。

这是我的完整脚本:

 $(function () { video = document.getElementById('vid'); navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia; navigator.getUserMedia( { audio: true, video: { facingMode: "user" } }, function (stream) { video.srcObject = stream; //video.src = window.URL.createObjectURL(stream); }, function (err) { alert(err.name); }); }); 

HTML:

 <video id="vid" muted autoplay></video> 

有没有人得到它的工作? 任何想法,将不胜感激。

解决它通过使用以下内容:

 $(function () { video = document.getElementById('vid'); video.style.width = document.width + 'px'; video.style.height = document.height + 'px'; video.setAttribute('autoplay', ''); video.setAttribute('muted', ''); video.setAttribute('playsinline', ''); var constraints = { audio: false, video: { facingMode: 'user' } } navigator.mediaDevices.getUserMedia(constraints).then(function success(stream) { video.srcObject = stream; }); }); 
Interesting Posts