Post

Replies

Boosts

Views

Activity

Issues with video feed (getUserMedia)
I have an iPhone 11 Pro Max running iOS14.2 and find that getUserMedia does not work in all scenarios. I set up my video feed as follows: &#9;if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) { &#9;&#9;throw new Error( &#9;&#9;&#9;'Browser API navigator.mediaDevices.getUserMedia not available'); &#9;} &#9;const video = document.getElementById('video'); &#9;const stream = await navigator.mediaDevices.getUserMedia({ &#9;&#9;'audio': false, &#9;&#9;'video': { &#9;&#9;&#9;facingMode: 'environment', &#9;&#9;&#9;// TODO: Currently set to window.innerWidth and innerHeight elsewhere? &#9;&#9;&#9;width: undefined, &#9;&#9;&#9;height: undefined &#9;&#9;}, &#9;}); &#9;// console.log(stream); &#9;video.srcObject = stream; &#9;return new Promise((resolve) => { &#9;&#9;video.onloadedmetadata = () => { &#9;&#9;&#9;resolve(video); &#9;&#9;}; &#9;}); } const loadVideo = async () => { &#9;const video = await setupCamera(); &#9;video.play(); &#9;return video; } My HTML is: <canvas id="videocanvas" width="100%" height="100%"> </canvas> <video id="video" &#9;&#9;&#9; autoplay &#9;&#9;&#9; playsinline &#9;&#9;&#9; muted &#9;&#9;&#9; style="display:none" &#9;&#9;&#9; width='100%'> </video> I'm using three.js to render a video texture, but also find this problem is demonstrable without this (see the Tensorflow PoseNet demo here https://github.com/tensorflow/tfjs-models/tree/master/posenet). The error displayed in the Javascript console for all of these is: [Error] A MediaStreamTrack ended due to a capture failure [Error] Unhandled Promise Rejection: Error: The video element has not loaded data yet. Please wait for `loadeddata` event on the <video> element. However, the BlazeFace demo works (see https://github.com/tensorflow/tfjs-models/tree/master/blazeface) yet appears to function in exactly the same way as the PoseNet code. I've tested this on 2 different iPhone 11s and an iPhone 12 mini with the same issues. All of the above code works on iOS 13.5 on an iPhone X without any issues. What has changed here between iOS 13.5 and iOS 14?
1
0
2.9k
Dec ’20