sye*_*yed 5 javascript ios webrtc getusermedia wkwebview
我有一个 IOS webview 应用程序和一个网站,可以navigator.mediaDevices.getUserMedia在拍照而不是压缩时触发脚本来降低图像质量。我们正在使用此脚本打开相机并拍摄图像。
它在 IOS safari 浏览器中工作正常,打开相机并以低质量拍摄照片,但在 IOS 应用程序 webview 中不起作用。
在 IOS 应用程序中,它显示黑屏,并且在调试应用程序时,它会抛出Unhandled Promise Rejection: notallowederror: User Denied即使在两次从浏览器端授予权限和另一次从应用程序端授予权限后也是如此。
<video id="video" playsinline autoplay muted> </video>
var constraints = { video: { facingMode: { exact: "environment", } } };
navigator.mediaDevices.getUserMedia(constraints)
.then(function (stream) {
var video = document.querySelector('video');
video.setAttribute('autoplay', '');
video.setAttribute('muted', '');
video.setAttribute('playsinline', '');
video.srcObject = stream;
video.onloadedmetadata = function (e) {
$('#containercamera').show();
};
})
Run Code Online (Sandbox Code Playgroud)
附:
| 归档时间: |
|
| 查看次数: |
793 次 |
| 最近记录: |