Wednesday, September 4, 2024

Free Tools

∆br∆ ∆br∆ Creating a complete screen recorder tool using RecordRTC involves a few steps, including setting up HTML, CSS, and JavaScript. Below is a basic implementation that incorporates RecordRTC to record audio and video. The design will be colorful and responsive. ### 1. HTML Create a file named `index.html` with the following content: ```html Screen Recorder

Screen Recorder Tool

``` ### 2. CSS Create a file named `styles.css` with the following content to style the tool and make it responsive: ```css body { font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background: linear-gradient(135deg, #ff7e5f, #feb47b); color: #fff; } .container { text-align: center; background: rgba(0, 0, 0, 0.7); padding: 20px; border-radius: 10px; max-width: 90%; width: 500px; } h1 { margin-bottom: 20px; } .controls { margin-bottom: 20px; } button { background-color: #28a745; border: none; color: white; padding: 10px 20px; margin: 0 5px; border-radius: 5px; cursor: pointer; font-size: 16px; transition: background-color 0.3s; } button:disabled { background-color: #6c757d; cursor: not-allowed; } button:hover:not(:disabled) { background-color: #218838; } video { width: 100%; height: auto; border-radius: 5px; } ``` ### 3. JavaScript Create a file named `script.js` with the following content to handle the recording functionality: ```javascript let recorder; let stream; document.getElementById('startRecording').addEventListener('click', async () => { try { stream = await navigator.mediaDevices.getDisplayMedia({ video: true, audio: true }); recorder = new RecordRTC(stream, { type: 'video', canvas: { width: 1280, height: 720 } }); recorder.startRecording(); document.getElementById('startRecording').disabled = true; document.getElementById('stopRecording').disabled = false; document.getElementById('downloadRecording').disabled = true; } catch (error) { console.error('Error accessing media devices.', error); } }); document.getElementById('stopRecording').addEventListener('click', () => { if (recorder) { recorder.stopRecording(() => { const blob = recorder.getBlob(); const url = URL.createObjectURL(blob); document.getElementById('preview').src = url; document.getElementById('preview').style.display = 'block'; document.getElementById('downloadRecording').href = url; document.getElementById('downloadRecording').download = 'recording.webm'; document.getElementById('downloadRecording').disabled = false; // Stop stream to release resources if (stream) { stream.getTracks().forEach(track => track.stop()); } }); document.getElementById('startRecording').disabled = false; document.getElementById('stopRecording').disabled = true; } }); ``` ### How It Works: - **HTML**: Provides the structure, including buttons for controlling the recording and a video element for playback. - **CSS**: Adds colorful and responsive styling. - **JavaScript**: Handles the recording logic, starting and stopping the recording, and updating the UI accordingly. To run this application, simply place the HTML, CSS, and JavaScript files in the same directory and open `index.html` in your browser. Ensure you have an active internet connection to load RecordRTC from the CDN.

No comments:

Post a Comment

भगवान श्रीकृष्ण ने अर्जुन को समझाया कि मनुष्य को अपने कर्तव्य का पालन करना चाहिए और अपने कर्मों के फल के प्रति अत्यधिक आसक्ति नहीं रखनी चाहि...