Файловый менеджер - Редактировать - /home/clickysoft/public_html/somni.clickysoft.net/public/html/capture-images/index.html
Назад
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Document</title> </head> <body> <style> #video { width: 100%; object-fit: cover; height: calc(100vh - 180px); } </style> <button id="requestPermission">Request Camera Permission</button> <button id="switchCamera">Switch Camera</button> <video id="video" style="display: none;" autoplay playsinline muted></video> <button id="capture" style="display: none;">Capture Image</button> <div id="capturedImagesContainer"></div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script> $(document).ready(function () { var video = $('#video').get(0); var capturedImagesContainer = $('#capturedImagesContainer'); var captureButton = $('#capture'); var requestButton = $('#requestPermission'); var switchCameraButton = $('#switchCamera'); var capturedImages = []; var counter = 0; var currentStream; $(requestButton).click(function () { // Request access to the camera and location navigator.mediaDevices.getUserMedia({ video: true }) .then(function (stream) { currentStream = stream; video.srcObject = stream; video.style.display = 'block'; video.play(); captureButton.css('display', 'inline-block'); // Request location access if ('geolocation' in navigator) { navigator.geolocation.getCurrentPosition(function (position) { console.log('Latitude: ' + position.coords.latitude); console.log('Longitude: ' + position.coords.longitude); }, function (error) { console.error('Error getting location: ' + error.message); }); } else { console.error('Geolocation is not supported by this browser.'); } navigator.mediaDevices.enumerateDevices() .then(function (devices) { var videoDevices = devices.filter(function (device) { return device.kind === 'videoinput'; }); // if (videoDevices.length > 1) { // switchCameraButton.css('display', 'inline-block'); // } }) .catch(function (err) { console.error("Error enumerating devices: " + err); }); }) .catch(function (err) { console.error("Error accessing the camera: " + err); }); }); $(switchCameraButton).click(function () { // Stop the current stream currentStream.getTracks().forEach(function (track) { track.stop(); }); // Get available video input devices and switch to the next one navigator.mediaDevices.enumerateDevices() .then(function (devices) { var videoDevices = devices.filter(function (device) { return device.kind === 'videoinput'; }); var currentDeviceId = video.srcObject.getTracks()[0].getSettings().deviceId; var nextDeviceId; for (var i = 0; i < videoDevices.length; i++) { if (videoDevices[i].deviceId !== currentDeviceId) { nextDeviceId = videoDevices[i].deviceId; break; } } navigator.mediaDevices.getUserMedia({ video: { deviceId: { exact: nextDeviceId } } }) .then(function (stream) { currentStream = stream; video.srcObject = stream; video.play(); }) .catch(function (err) { console.error("Error switching camera: " + err); }); }) .catch(function (err) { console.error("Error enumerating devices: " + err); }); }); $(captureButton).click(function () { if (counter >= 4) { event.preventDefault(); } else { var canvas = document.createElement('canvas'); canvas.width = video.videoWidth; canvas.height = video.videoHeight; var context = canvas.getContext('2d'); context.drawImage(video, 0, 0, canvas.width, canvas.height); var imageData = canvas.toDataURL('image/png'); var imgElement = $('<img>').attr('src', imageData); capturedImagesContainer.append(imgElement); capturedImages.push(imageData); counter++; } }); }); </script> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка