Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript iOS 11 getUserMedia不工作?_Javascript_Jquery_Ios_Webrtc_Getusermedia - Fatal编程技术网

Javascript iOS 11 getUserMedia不工作?

Javascript iOS 11 getUserMedia不工作?,javascript,jquery,ios,webrtc,getusermedia,Javascript,Jquery,Ios,Webrtc,Getusermedia,苹果发布声明称,getUserMedia将在iOS 11上全面运行。在安装iOS 11 Beta版本5后,我确实收到一条消息,我的网站请求访问我的相机和麦克风,但这条线似乎是: video.src = window.URL.createObjectURL(stream); 或: 不起作用。没有错误,没有例外,只是没有手机摄像头的图片 以下是我的完整脚本: $(function () { video = document.getElementById('vid'); nav

苹果发布声明称,
getUserMedia
将在iOS 11上全面运行。在安装iOS 11 Beta版本5后,我确实收到一条消息,我的网站请求访问我的相机和麦克风,但这条线似乎是:

video.src = window.URL.createObjectURL(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:



有人让它工作了吗?如果您有任何想法,我们将不胜感激。

使用以下方法解决此问题:

$(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;
    });
});

是的,它被移动到navigator.mediaDevices。还要注意的是,虽然视频似乎无处不在,但音频在iPodtouch上不起作用-要求音频会导致过度约束的错误。我在视频中看到一个黑屏,我的代码几乎相同。你面对过这个问题吗?感谢解决了黑屏问题:我一直遇到这里描述的相同问题:尽管我运行的是iOS11。1@IvanPandžić如果您在代码中发布一个新问题并将其链接到我这里作为评论,我将很乐意提供帮助。投票支持我的问题,asnwer也将不胜感激:)
<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;
    });
});