https://developers.google.com/funding-choices/fc-api-docs NewsWave: Screen Recorder Tools

Saturday, September 9, 2023

Screen Recorder Tools



Screen Recorder Tool

Screen Recorder Tool

// Import RecordRTC library import RecordRTC from 'recordrtc'; // Initialize variables let mediaStream; let recorder; // Get HTML elements const startRecordingButton = document.getElementById('startRecording'); const stopRecordingButton = document.getElementById('stopRecording'); const recordedVideo = document.getElementById('recordedVideo'); // Add event listeners startRecordingButton.addEventListener('click', startRecording); stopRecordingButton.addEventListener('click', stopRecording); // Function to start recording function startRecording() { navigator.mediaDevices .getDisplayMedia({ video: true }) .then(function (stream) { mediaStream = stream; recorder = new RecordRTC(stream, { type: 'video', mimeType: 'video/webm', }); recorder.startRecording(); startRecordingButton.disabled = true; stopRecordingButton.disabled = false; }) .catch(function (error) { console.error('Error accessing screen:', error); }); } // Function to stop recording function stopRecording() { recorder.stopRecording(function () { mediaStream.getTracks().forEach((track) => track.stop()); recordedVideo.src = URL.createObjectURL(recorder.getBlob()); recordedVideo.style.display = 'block'; startRecordingButton.disabled = false; stopRecordingButton.disabled = true; }); }

No comments:

Post a Comment