Copy from
🠋
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Screen Recorder</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
}
#app {
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
h1 {
color: #333;
}
#video-container {
margin-top: 20px;
display: none;
}
#record-button, #stop-button {
padding: 10px 20px;
font-size: 16px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
#stop-button {
background-color: #dc3545;
}
</style>
</head>
<body>
<div id="app">
<h1>Screen Recorder</h1>
<button id="record-button">Start Recording</button>
<button id="stop-button" disabled>Stop Recording</button>
<div id="video-container">
<video id="recorded-video" controls></video>
</div>
</div>
<script src="https://cdn.webrtc-experiment.com/RecordRTC.js"></script>
<script>
const recordButton = document.getElementById('record-button');
const stopButton = document.getElementById('stop-button');
const videoContainer = document.getElementById('video-container');
const recordedVideo = document.getElementById('recorded-video');
let recorder;
recordButton.addEventListener('click', startRecording);
stopButton.addEventListener('click', stopRecording);
function startRecording() {
recordButton.disabled = true;
stopButton.disabled = false;
navigator.mediaDevices.getDisplayMedia({ video: true, audio: true })
.then(stream => {
recordedVideo.srcObject = stream;
recordedVideo.play();
recorder = RecordRTC(stream, {
type: 'video',
mimeType: 'video/webm',
bitsPerSecond: 128000
});
recorder.startRecording();
})
.catch(error => console.error('Error accessing screen:', error));
}
function stopRecording() {
recordButton.disabled = false;
stopButton.disabled = true;
recorder.stopRecording(() => {
recordedVideo.srcObject = null;
recordedVideo.src = URL.createObjectURL(recorder.getBlob());
recordedVideo.play();
videoContainer.style.display = 'block';
});
}
</script>
</body>
</html>
🠉
Till above
Comments
Post a Comment