简体   繁体   English

iOS getUserMedia 的 Bowser 未定义

[英]Bowser for iOS getUserMedia is undefined

I'm trying to get WebRTC to work with the Bowser browser for iOS. But whatever I try navigator.getUserMedia is undefined.我试图让 WebRTC 与 iOS 的Bowser浏览器一起工作。但无论我尝试navigator.getUserMedia是未定义的。

I'm testing the page on an iPhone6 running iOS 8.3.我正在运行 iOS 8.3 的 iPhone6 上测试该页面。

This is how I've set it up:这就是我的设置方式:

var localMediaStream;

navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;

window.onload = function() {
    var video = document.getElementById('video');

    navigator.getUserMedia({video: true}, function(stream) {
        video.src = window.URL.createObjectURL(stream);

        localMediaStream = stream;
    }, function(err) {
        if(err) throw err;
    });
};

The error I get is:我得到的错误是:

TypeError: undefined is not a function (evaluating 'navigator.getUserMedia')

If I don't feature-detect and use navigator.webkitGetUserMedia directly (which is as I understand it the method that should exist in Bower) I get the same error.如果我不进行功能检测并直接使用navigator.webkitGetUserMedia (据我所知,这是 Bower 中应该存在的方法),我会得到同样的错误。

Do this做这个

navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;

inside onload内部加载

But for me it doesn't work when you open the page for the first time.但是对我来说,第一次打开页面时它不起作用。 After page refresh it works.页面刷新后就可以了。

UPD: It's due to the fact that Bowser's javascript was injected too late (or not injected at all). UPD:这是因为 Bowser 的 javascript 注入太晚(或根本没有注入)。 It was a iOs's webview problem.这是一个 iOs 的 webview 问题。 But bowser's team are saying that they have replaced it with the new control not web view but the newer one (don't remember the name, sorry).但是 bowser 的团队说他们已经用新的控件而不是 Web 视图替换了它,而是用较新的控件(不记得名字,抱歉)。

navigator.mediaDevices.getUserMedia(..)

should be fully supported by Safari 11 and up. Safari 11 及更高版本应得到全面支持。 It can be only accessed from a SSL domain though, so if developing locally, try to add a https:// prefix to your alias.它只能从 SSL 域访问,因此如果在本地开发,请尝试将https://前缀添加到您的别名。 https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia https://developer.mozilla.org/zh-CN/docs/Web/API/MediaDevices/getUserMedia

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM