Skip to content

Instantly share code, notes, and snippets.

@derMani
Created February 29, 2016 21:22
Show Gist options
  • Save derMani/4fd8d1fe7f7c6fa2aec2 to your computer and use it in GitHub Desktop.
Save derMani/4fd8d1fe7f7c6fa2aec2 to your computer and use it in GitHub Desktop.
window.URL = window.URL;
$("#videoDiv").remove();
$("body").prepend("<div id='videoDiv' style='background-color:black;z-index:99999999999999;position:absolute;left:0;top:0'><video id='myVideo' autoplay></video></div>");
if (window.localStream) {
window.localStream.getTracks().forEach(function(track) {
track.stop();
});
}
// "835acea08d27ea4ae22fbe97aaf8fb554e4cb0b7d106a77e9407cd87ed1175a6"
// "63050f06f93b77644f25950f3b581df7e6e0d4cf2742e8efa9357cf71b907678"
// 365104945f8037602756a03b5eb65285958235871816898b61155c9cbf8575fb
// 67c4e3b400a461c9cba364dbc31a11f4fda2205bbe582f82fd2c5e75bae8b018
// 70dcbec48332bdb034ee13267369f81298bc3c651b775db92d733d29c074f43b
// 25778b0e4c1cd51fbc4573bd085aca767693da7b5c71777e6337c7c1498b3d3f
constraints = {
video: {
'mandatory': {
'sourceId': '70dcbec48332bdb034ee13267369f81298bc3c651b775db92d733d29c074f43b',
maxWidth: 320,
minWidth: 320,
maxHeight: 240,
minHeight: 240
}
}
};
function successCallback(stream) {
var videoElement = document.querySelector('video');
window.localStream = stream;
videoElement.src = window.URL.createObjectURL(localStream);
setTimeout(function() {console.log($('#myVideo').css("width"),$('#myVideo').css("height"));}, 2000);
}
function errorCallback(error) {
console.log("asdfdsfdsfsf");
console.log(error);
}
navigator.mediaDevices.getUserMedia(constraints)
.then(successCallback)
.catch(function (error) {
console.log('getUserMedia error!', error);
});
console.log("started");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment