Spaces:
Running
Running
File size: 1,147 Bytes
b27cb15 d6fb0af eb315e4 d6fb0af eb315e4 d6fb0af b27cb15 d6fb0af 693b035 d6fb0af 693b035 b27cb15 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
// scripts/video.js
async function startRecording() {
// First, check if the browser supports the getDisplayMedia API at all.
if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
// If it exists, try to use it.
try {
const stream = await navigator.mediaDevices.getDisplayMedia({
video: true
});
// If the user gives permission, this code will run.
alert("Screen access granted! Recording can now begin.");
// (The actual logic to handle the video stream would go here)
} catch (error) {
// This will run if the user denies permission.
alert(`Screen recording was cancelled or denied. Error: ${error.message}`);
}
} else {
// If the API doesn't exist, inform the user gracefully.
alert("Sorry, your browser or current viewing environment does not support screen recording.");
}
}
export function initVideo() {
const startBtn = document.getElementById('start-recording');
if (startBtn) {
startBtn.addEventListener('click', startRecording);
}
} |