[英]Access camera or webcam without webRTC
In my website, it needs to access camera or webcam.在我的网站中,它需要访问摄像头或网络摄像头。 But webRTC is not supported yet on ios webview based on https://forums.developer.apple.com/thread/88052 (please cmiiw).
但是基于https://forums.developer.apple.com/thread/88052 (请cmiiw)的ios webview尚不支持webRTC。 So, I'm trying to find a way to access it without webRTC.
因此,我试图找到一种无需 webRTC 即可访问它的方法。 Is there any?
有没有?
And is this following code, a part of utilizing webRTC?以下代码是利用 webRTC 的一部分吗? Because the console.log shows up on ios webview
因为 console.log 显示在 ios webview 上
function hasGetUserMedia() { return !!(navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia); } //then, somewhere in the code if (!hasGetUserMedia()) { console.log( "webRTC is not supported in your browser" );//it shows up on ios webview } //other code navigator.mediaDevices.getUserMedia({ audio: false, //no audio video: {deviceId: {exact: videoSource.camera_id} } })
If yes, so what's the workaround which not using webRTC, and can be run on android webview, ios webview, and web browsers?如果是,那么不使用 webRTC 并且可以在 android webview、ios webview 和 web 浏览器上运行的解决方法是什么?
We now have access to getUserMedia
on iOS WebViews!我们现在可以在 iOS WebViews 上访问
getUserMedia
!
As of iOS 14.3, iOS now allows access to getUserMedia
in a WKWebView
从 iOS 14.3 开始,iOS 现在允许访问
WKWebView
getUserMedia
Whenever I have questions about browser features like this, I find it very helpful to check out caniuse.com .每当我对这样的浏览器功能有疑问时,我发现查看caniuse.com非常有帮助。 In this case, there is a note on the entry for Safari & Chrome for iOS
在这种情况下,iOS 版 Safari 和 Chrome 的条目上有一个注释
Before iOS 14.3
getUserMedia
returned no video input devices inUIWebView
orWKWebView
, but only directly in Safari在 iOS 14.3 之前
getUserMedia
在UIWebView
或WKWebView
没有返回视频输入设备,而是直接在 Safari 中返回
Prior to 2021, we could not access getUserMedia
on iOS outside of Safari.在 2021 年之前,我们无法在 Safari 之外的 iOS 上访问
getUserMedia
。 So back then, a workaround was to build a website and direct iOS users to visit the site in Safari instead of making a native app for iOS.因此,当时的解决方法是建立一个网站并引导 iOS 用户在 Safari 中访问该网站,而不是为 iOS 制作本机应用程序。
getUserMedia
controls access to a user's camera and microphone, whereas WebRTC helps you send that audio/video to another client, like in a video chat. getUserMedia
控制对用户摄像头和麦克风的访问,而 WebRTC 可帮助您将该音频/视频发送到另一个客户端,例如在视频聊天中。 Here you're stuck on getting the video in the first place so you don't need to worry about WebRTC yet, but when you do, I recommend you check out This article that helped me.在这里,您首先坚持获取视频,因此您无需担心 WebRTC,但是当您这样做时,我建议您查看这篇对我有帮助的文章。
And if you want to test getUserMedia
or WebRTC functions yourself, try using These provided samples , so that you can be sure that it is not the fault of your own code :)如果你想自己测试
getUserMedia
或 WebRTC 功能,请尝试使用这些提供的示例,这样你就可以确定这不是你自己代码的错:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.