Last active
March 30, 2020 12:05
-
-
Save mxriverlynn/9493718 to your computer and use it in GitHub Desktop.
webrtc webcam in 20 lines
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
body { | |
margin: 0px; | |
padding: 0px; | |
} | |
#player { | |
width: 100%; | |
height: 100%; | |
} |
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> | |
<head> | |
<title>WebRTC WebCam</title> | |
<link rel="stylesheet" href="webcam.css"/> | |
<script src="webcam.js"></script> | |
</head> | |
<video id="player" autoplay="true"></video> | |
</html> |
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
(function(){ | |
var mediaOptions = { audio: false, video: true }; | |
if (!navigator.getUserMedia) { | |
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; | |
} | |
if (!navigator.getUserMedia){ | |
return alert('getUserMedia not supported in this browser.'); | |
} | |
navigator.getUserMedia(mediaOptions, success, function(e) { | |
console.log(e); | |
}); | |
function success(stream){ | |
var video = document.querySelector("#player"); | |
video.src = window.URL.createObjectURL(stream); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
""looking for complete javascript code to access multiple camera drivers"""".
I am trying to use multiple cameras on web application . List of camera drivers should come in the drop down. I should be able to choose required camera driver from the drop down. Based on my selection, i will capture the photo. Whenver i change the drop down option, the corresponding camera driver should open."
CURRENTLY USING RTCMulticonnection for accessing multiple devices *