Screen Recorder Tool
Screen Recorder Tool
body {
font-family: 'Arial', sans-serif;
background: #f0f0f0;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
color: #333;
}
.container {
background: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
max-width: 400px;
width: 100%;
}
h1 {
margin-bottom: 20px;
}
video {
width: 100%;
border: 1px solid #ccc;
border-radius: 5px;
margin-bottom: 20px;
}
.controls {
display: flex;
justify-content: space-between;
}
.button {
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
transition: background 0.3s;
}
.start {
background: #28a745;
color: #fff;
}
.start:hover {
background: #218838;
}
.stop {
background: #dc3545;
color: #fff;
}const startRecordingButton = document.getElementById('startRecording');
const stopRecordingButton = document.getElementById('stopRecording');
const downloadRecordingButton = document.getElementById('downloadRecording');
const previewVideo = document.getElementById('preview');
let recorder;
let recordedChunks;
startRecordingButton.addEventListener('click', async () => {
const stream = await navigator.mediaDevices.getDisplayMedia({
video: true,
audio: true
});
recorder = new RecordRTC(stream, {
type: 'video',
mimeType: 'video/webm; codecs=vp8',
bitsPerSecond: 128000
});
recorder.startRecording();
previewVideo.srcObject = stream;
startRecordingButton.disabled = true;
stopRecordingButton.disabled = false;
downloadRecordingButton.disabled = true;
});
stopRecordingButton.addEventListener('click', () => {
recorder.stopRecording(() => {
const blob = recorder.getBlob();
previewVideo.srcObject.getTracks().forEach(track => track.stop());
previewVideo.src = URL.createObjectURL(blob);
recordedChunks = blob;
startRecordingButton.disabled = false;
stopRecordingButton.disabled = true;
downloadRecordingButton.disabled = false;
});
});
downloadRecordingButton.addEventListener('click', () => {
const url = URL.createObjectURL(recordedChunks);
const a = document.createElement('a');
a.style.display = 'none';
a.href = url;
a.download = 'recording.webm';
document.body.appendChild(a);
a.click();
URL.revokeObjectURL(url);
});
.stop:hover {
background: #c82333;
}
.download {
background: #007bff;
color: #fff;
}
.download:hover {
background: #0056b3;
}