HOME > MIDI/AUDIO LAB

Study about Video through getUserMedia

内臓カメラの映像を、getUserMediaを使ってブラウザに表示します。

{
/*	navigator.getUserMedia = ( navigator.getUserMedia ||
		navigator.webkitGetUserMedia ||
		navigator.mozGetUserMedia ||
		navigator.msGetUserMedia);
*/

// constraints
var mConstraints = {
	video: true,
	audio: false
};

// constraints (Chrome)
if (window.chrome) {
	mConstraints = {
		video: true,
		audio: false
	};
}

navigator.getUserMedia(

	mConstraints,

	function(stream){
		var video = document.querySelector('video');
		video.srcObject = stream;
		localMediaStream = stream;
		video.onloadedmetadata = function(e) {
			video.play();
		};

	},

	function(e) {
		console.log(e);
	}
);

}



Copyright © Mikata Hawa 2015-2020
fabercastell679@yahoo.com