StreamAI / scripts /video.js
privateuserh's picture
Update scripts/video.js
d6fb0af verified
raw
history blame
1.23 kB
// scripts/video.js
// This function will contain the logic for the video recording feature.
async function startRecording() {
try {
// Use the Media Devices API to request screen access from the user.
// This will cause the browser to show a "Share your screen" permission pop-up.
const stream = await navigator.mediaDevices.getDisplayMedia({
video: {
mediaSource: "screen"
}
});
// For now, we will just log that we got permission.
// In a real app, you would use this 'stream' object to record a video.
console.log("Screen access granted!", stream);
alert("Screen access granted! Recording has started (in theory).");
} catch (error) {
// This will run if the user clicks "Cancel" on the permission pop-up.
console.error("Error starting screen recording:", error);
alert(`Could not start recording. Error: ${error.message}`);
}
}
export function initVideo() {
const startBtn = document.getElementById('start-recording');
if (startBtn) {
// We replace the old alert with a call to our new function.
startBtn.addEventListener('click', startRecording);
}
}