mirror of
https://github.com/pierre42100/comunic
synced 2024-09-29 03:22:49 +00:00
47 lines
1.3 KiB
JavaScript
Executable File
47 lines
1.3 KiB
JavaScript
Executable File
/*
|
|
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree.
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
// Put variables in global scope to make them available to the browser console.
|
|
var canvas = window.canvas = document.querySelector('canvas');
|
|
canvas.width = 480;
|
|
canvas.height = 360;
|
|
|
|
var button = document.getElementById('bouton_prendre_photo');
|
|
button.onclick = function() {
|
|
canvas.getContext('2d').
|
|
drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
};
|
|
|
|
var video = document.querySelector('video');
|
|
|
|
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
|
|
navigator.mozGetUserMedia;
|
|
|
|
var constraints = {
|
|
audio: false,
|
|
video: true
|
|
};
|
|
|
|
function successCallback(stream) {
|
|
window.stream = stream; // make stream available to browser console
|
|
if (window.URL) {
|
|
video.src = window.URL.createObjectURL(stream);
|
|
} else {
|
|
video.src = stream;
|
|
}
|
|
}
|
|
|
|
function errorCallback(error) {
|
|
console.log('navigator.getUserMedia error: ', error);
|
|
}
|
|
|
|
// Activation automatique de la demande de la webcam (désactivé)
|
|
// navigator.getUserMedia(constraints, successCallback, errorCallback);
|