gpt4 book ai didi

ios - undefined 不是对象(评估 'navigation.mediaDevices.getUserMedia')

转载 作者:行者123 更新时间:2023-12-01 16:05:16 25 4
gpt4 key购买 nike

我想打开一个相机扫描仪,下面是在 android 中正常工作但在 ios 中出现错误的代码

TypeError: undefined is not an object (evalution'navigation.mediaDevices.getUserMedia')


这是完整的教程链接 https://devdactic.com/pwa-qr-scanner-ionic/
非常感谢您的小帮助
async startScan() {
// Not working on iOS standalone mode!
const stream = await navigator.mediaDevices.getUserMedia({
video: { facingMode: 'environment' }
});

this.videoElement.srcObject = stream;
// Required for Safari
this.videoElement.setAttribute('playsinline', true);

this.loading = await this.loadingCtrl.create({});
await this.loading.present();

this.videoElement.play();
requestAnimationFrame(this.scan.bind(this));
}

async scan() {
if (this.videoElement.readyState === this.videoElement.HAVE_ENOUGH_DATA) {
if (this.loading) {
await this.loading.dismiss();
this.loading = null;
this.scanActive = true;
}

this.canvasElement.height = this.videoElement.videoHeight;
this.canvasElement.width = this.videoElement.videoWidth;

this.canvasContext.drawImage(
this.videoElement,
0,
0,
this.canvasElement.width,
this.canvasElement.height
);
const imageData = this.canvasContext.getImageData(
0,
0,
this.canvasElement.width,
this.canvasElement.height
);
const code = jsQR(imageData.data, imageData.width, imageData.height, {
inversionAttempts: 'dontInvert'
});

if (code) {
this.scanActive = false;
this.scanResult = code.data;
this.showQrToast();
} else {
if (this.scanActive) {
requestAnimationFrame(this.scan.bind(this));
}
}
} else {
requestAnimationFrame(this.scan.bind(this));
}
}

最佳答案

getUserMediaWKWebView 上不可用, 电容器使用。所以你将无法使用它,除非 Apple 制造 getUserMedia将来可用。

关于ios - undefined 不是对象(评估 'navigation.mediaDevices.getUserMedia'),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62893456/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com