我正在尝试理解,我很确定问题不在告诉我什么。
我正在使用Vue.js构建PWA。当我启动相机时,它无法在iOS(v11 +)上运行。我尝试了许多变体,但不知道发生了什么以及如何在Safari Developer工具中正确调试已编译的代码(断点将不起作用)。
代码如下:
async init () {
// Media Device settings
const constraints = {
audio: false,
video: {
facingMode: (this.camera.mode === 'front') ? 'user' : { exact: 'environment' },
width: this.camera.size.width,
height: this.camera.size.height
}
}
try {
const stream = await navigator.mediaDevices.getUserMedia(constraints)
this.tracks = stream.getVideoTracks()
this.video.srcObject = stream
// Toggle the camera state
this.toggleCamera(true)
// Check for realtime validation
if (this.realtime) {
this.validatePhotoRealtime()
}
} catch (e) {
this.handleErrorMessage(`getUserMedia error: ${e.name}`, e)
}
}
这是我在控制台窗口中看到的:
Trying to call getUserMedia from an insecure document.
有什么办法调试此错误吗?
====更新====
在localhost上开发并且没有适用于开发环境的https时,进行yarn server
并通过网络连接到服务的IP
但这没有帮助。
答案 0 :(得分:1)
不幸的是,当您将应用程序用作PWA时,Apple不允许使用WebRTC。 看一下这个链接。
答案 1 :(得分:1)
在最新版本的safari中,您可以从Web检查器窗口中允许不安全的网站。看到此回复:https://stackoverflow.com/a/59770868/2440064