javascript Chrome 和 Firefox 无法访问 iPhone 相机

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51501642/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 09:34:27  来源:igfitidea点击:

Chrome and Firefox are not able to access iPhone Camera

javascriptiphonehtmlgoogle-chromemozilla

提问by Simon Fernandes

The below code of HTML

下面的 HTML 代码

<video id="video" class="video" height="400" width="400" playsinline autoplay muted loop></video>

and JavaScript

和 JavaScript

var video = document.getElementById("video");

navigator.mediaDevices.getUserMedia({video: true, audio: false})
    .then(function(s) {
    stream = s;
    video.srcObject = s;
    video.play();
  })

The link works fine on all Browsers in Android device, also works fine on Safari browser of iPhone devices, but it does not even ask camera permission for other Browsers like Chrome and Firefox on iPhone Devices.

该链接在 Android 设备中的所有浏览器上都可以正常工作,在 iPhone 设备的 Safari 浏览器上也可以正常工作,但它甚至不要求其他浏览器(如 iPhone 设备上的 Chrome 和 Firefox)的相机许可。

回答by Mark Henderson

Chrome and FireFox on iOS still use the iOS WebKit rendering engine. getUserMediais only available in Safari, not other browsers on iOS.

iOS 上的 Chrome 和 FireFox 仍然使用 iOS WebKit 渲染引擎。getUserMedia仅在 Safari 中可用,在 iOS 上的其他浏览器中不可用。

This is currently being tracked here: https://bugs.chromium.org/p/chromium/issues/detail?id=752458- but given it was first reported over a year ago and just 5 days ago it was updated to say it hasn't been fixed, I am not holding my breath.

目前正在此处对其进行跟踪:https: //bugs.chromium.org/p/chromium/issues/detail?id=752458- 但鉴于它是一年多前首次报道的,并且仅在 5 天前它被更新为这样说还没有解决,我没有屏住呼吸。

回答by devnullpointer

Chrome on iOS (13.1.1) is able to access both front and rear cameras using html5 proper input tag for image capture, but yeah still a bummer they don't support the getUserMedia for video streaming.

iOS (13.1.1) 上的 Chrome 能够使用 html5 正确的输入标签来访问前后摄像头以进行图像捕获,但是仍然令人遗憾的是他们不支持用于视频流的 getUserMedia。

Here's a fiddle

这是一把小提琴

For Front:
<input type="file" accept="image/*" capture="environment">

For Rear:
<input type="file" accept="image/*" capture="user">