how to get stream from user media code example
Example 1: getusermedia example
var constraints = { audio: true, video: { width: 1280, height: 720 } };
navigator.mediaDevices.getUserMedia(constraints)
.then(function(mediaStream) {
var video = document.querySelector('video');asdfds
video.srcObject = mediaStream;
video.onloadedmetadata = function(e) {
video.play();
};
})
.catch(function(err) { console.log(err.name + ": " + err.message); });
Example 2: javascript navigator.mediaDevices.getUserMedia
The deprecated Navigator.getUserMedia() method prompts the user for permission
to use up to one video input device (such as a camera or shared screen) and up
to one audio input device (such as a microphone) as the source for a
MediaStream.
If permission is granted, a MediaStream whose video and/or audio tracks come
from those devices is delivered to the specified success callback. If
permission is denied, no compatible input devices exist, or any other error
condition occurs, the error callback is executed with a MediaStreamError object
describing what went wrong. If the user instead doesn't make a choice at all,
neither callback is executed.