Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DaveVoyles/2ac04742e50fc1d8fe3e to your computer and use it in GitHub Desktop.
Save DaveVoyles/2ac04742e50fc1d8fe3e to your computer and use it in GitHub Desktop.
InitializeVideoStream - Get User Media
// initializeVideoStream() - Callback function when getUserMedia() returns successfully with a mediaStream object
// 1. Set the mediaStream on the video tag
// 2. Use 'srcObject' attribute to determine whether to use the standard-based API or the legacy version
var initializeVideoStream = function(stream) {
mediaStream = stream;
var video = document.getElementById('videoTag');
if (typeof (video.srcObject) !== 'undefined') {
video.srcObject = mediaStream;
}
else {
video.src = URL.createObjectURL(mediaStream);
}
if (webcamList.length > 1) {
document.getElementById('switch').disabled = false;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment