var streamObj = null;
var videoTag = document.getElementById('videoLocal');
function start() {
var constraints = {
audio: false,
video: {
width: {exact: 1280},
height: {exact: 720}
}
};
navigator.mediaDevices.getUserMedia(constraints)
.then(function(stream) {
//Play the media stream in the video element
streamObj = stream;
videoTag.srcObject = stream;
//video.play();
logStream(stream);
videoTag.addEventListener("loadedmetadata", function(e) {
console.log('loadedmetadata');
});
videoTag.addEventListener("loadeddata", function(e) {
console.log('loadeddata');
update(vinfo, videoTag.videoWidth + " x " + videoTag.videoHeight);
});
})
.catch(function(error) {
if (error.name === 'ConstraintNotSatisfiedError') {
console.error('The resolution ' + constraints.video.width.exact + 'x' +
constraints.video.width.exact + ' px is not supported by your device.');
} else if (error.name === 'PermissionDeniedError') {
console.error('Permissions have not been granted to use your camera and ' +
'microphone, you need to allow the page access to your devices in ' +
'order for the demo to work.');
} else {
console.error('getUserMedia error: ' + error.name, error);
}
});
}
function logStream(stream) {
var tracks = stream.getTracks();
console.log('stream ID:', stream.id);
for (var i = 0; i < tracks.length; i++) {
console.log("track ID:", tracks[i].id, "track label:", tracks[i].label, "kind:", tracks[i].kind);
}
}
function stop() {
//streamObj.stop();
var tracks = streamObj.getTracks();
for (var i = 0; i < tracks.length; i++) {
tracks[i].stop();
}
videoTag.srcObject = null; //set video tag src to null
}
function test() {
console.log('adapter:', adapter);
console.log('browserDetails:', adapter.browserDetails);
console.log('extractVersion:',...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.