Skip to content

Commit

Permalink
add gum_facingmode.html
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-ivar committed Jul 31, 2024
1 parent 37052c5 commit 1e3417f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions gum_facingmode.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<html>
<meta charset=utf-8>
<button id="front">Front</button><button id="back">Back</button>
<div id="div"></div>
<video id="video" autoplay></video><br>
<script>
const console = {log: msg => div.innerHTML += `${msg}<br>`};

async function gum(exact) {
try {
if (video.srcObject) {
video.srcObject.getVideoTracks()[0].stop();
}
video.srcObject = await navigator.mediaDevices.getUserMedia({video: {facingMode: {exact}}});
} catch (e) {
console.log(e);
}
}

front.onclick = () => gum("user");
back.onclick = () => gum("environment");

</script>
</html>

0 comments on commit 1e3417f

Please sign in to comment.