Screen Recorder
{ let recorder; const videoElement = document.getElementById('recording'); const startBtn = document.getElementById('startBtn'); const stopBtn = document.getElementById('stopBtn'); startBtn.addEventListener('click', startRecording); stopBtn.addEventListener('click', stopRecording); function startRecording() { navigator.mediaDevices.getUserMedia({ video: true, audio: true }) .then((stream) => { recorder = RecordRTC(stream, { type: 'video' }); recorder.startRecording(); videoElement.srcObject = stream; startBtn.disabled = true; stopBtn.disabled = false; }) .catch((error) => console.error('Error accessing media devices:', error)); } function stopRecording() { recorder.stopRecording(() => { videoElement.src = videoElement.srcObject = null; videoElement.src = URL.createObjectURL(recorder.getBlob()); recorder.destroy(); recorder = null; startBtn.disabled = false; stopBtn.disabled = true; }); } });