如何让 iOS 拥有 2 个视频流?
现在,如果我使用iPhone或iPad并尝试显示两个流,一个是黑色,另一个是作品。我该怎么做才能使两者都起作用?这在我的笔记本电脑上都可以在所有浏览器上工作。
<script>
navigator.mediaDevices.getUserMedia({ audio: true, video: true})
.then(function(camera) { document.getElementById("video1").srcObject = camera;})
.catch(function(error) { console.error("ERROR", error) });
navigator.mediaDevices.getUserMedia({audio: true, video: { width: 400, height: 200}})
.then(function(remote_camera) { document.getElementById("video2").srcObject = remote_camera;})
.catch(function(error) { console.error("ERROR", error) });
</script>
<video id="video1" controls autoplay playsinline></video>
<video id="video2" controls autoplay playsinline></video>
Right now if I use my iPhone or iPad and try to display two streams, one is black and the other works. What can I do to get both working? This works fine on all browsers with my laptop.
<script>
navigator.mediaDevices.getUserMedia({ audio: true, video: true})
.then(function(camera) { document.getElementById("video1").srcObject = camera;})
.catch(function(error) { console.error("ERROR", error) });
navigator.mediaDevices.getUserMedia({audio: true, video: { width: 400, height: 200}})
.then(function(remote_camera) { document.getElementById("video2").srcObject = remote_camera;})
.catch(function(error) { console.error("ERROR", error) });
</script>
<video id="video1" controls autoplay playsinline></video>
<video id="video2" controls autoplay playsinline></video>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
iOS 上的 Safari 一次不支持多个活动相机。
https://bugs.webkit.org/show_bug.cgi?id=238492 是关于它的最新错误报告,但这种行为早在 2018 年就已经记录在案:https://webrtchacks.com/guide-to-safari-webrtc/
Safari on iOS does not support more than a single active camera at a time.
https://bugs.webkit.org/show_bug.cgi?id=238492 is the most recent bug report about it but this behavior has been documented back in 2018 already: https://webrtchacks.com/guide-to-safari-webrtc/