Created
May 9, 2020 06:58
-
-
Save Regentag/0673add38a37c6ce77c197579fcef4e7 to your computer and use it in GitHub Desktop.
iPhone iOS에서 작동하는 getUserMedia() 예제 - iOS 13.3.1에서 테스트 됨
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | |
<title>getUserMedia() example</title> | |
<script type="text/javascript"> | |
function enableMedia() { | |
var video = document.getElementById("captureVideo"); | |
navigator.getUserMedia = navigator.mediaDevices.getUserMedia || navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; | |
if (navigator.getUserMedia) { | |
navigator.mediaDevices.getUserMedia( {audio: false, video: { facingMode: "environment"} } ) | |
.then(function(stream) { | |
video.srcObject = stream; | |
video.onloadedmetadata = function(e) { | |
video.play(); | |
}; | |
}) | |
.catch(function(e) { | |
console.log("error: " + e); | |
}) | |
} else { | |
console.log("getUserMedia() not available.") | |
video.src = 'somevideo.webm'; // fallback. | |
} | |
} | |
$(document).ready( enableMedia ) | |
</script> | |
</head> | |
<body> | |
<h2>capture example</h2> | |
<video id="captureVideo" controls autoplay muted playsinline style="width:100%;height:100%;border:1px solid black"></video> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment