iOS 11.3.1上的PWA中的getUserMedia() [英] getUserMedia() in PWA on iOS 11.3.1
问题描述
我正在尝试构建我的webapp的PWA。我的webapp使用getUserMedia让用户拍照。 webapp按预期工作。浏览器要求访问摄像头的权限,如果用户接受它,该应用程序将继续工作。现在,我做了一个PWA,除了相机之外。用户没有得到提示访问其相机的提示,这是我认为的问题所在。有没有办法触发相机访问:
I'm trying to build a PWA of my webapp. My webapp makes use of getUserMedia to let the user make a picture. the webapp works as expected. the browser asks permission to access the camera and if a user accepts it, the app continues to work. Now, I made a PWA which works except for the camera. The user doesn't get a prompt to give access to its camera which is where I think is the problem. Is there any way to trigger the camera access:
let constraints = {
video: {
facingMode: "user"
},
audio: false
};
navigator.mediaDevices
.getUserMedia(constraints)
.then(function (stream) {
track = stream.getTracks()[0];
cameraView.srcObject = stream;
})
.catch(function (error) {
console.error("Oops. Something is broken.", error);
});
在PWA中是这样的?或者这是不可能的(还)?如果没有,是否有任何计划让iOS上的PWA具备此功能?
like such inside a PWA? or is this not possible (yet)? If not, are there any plans for PWA's on iOS to have this functionality?
推荐答案
在您的manifest.json文件中,您可能有显示:独立
。如果您将其更改为浏览器
,它应该可以正常工作。我现在面临同样的问题,似乎iOS不允许访问Safari主视图外的webrtc
On your manifest.json file, you probably have "display": "standalone"
. If you change it to browser
it should work. I'm facing the same problem now and it seems that iOS doesn't allow access to webrtc outside Safari main view
这篇关于iOS 11.3.1上的PWA中的getUserMedia()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!