Skip to content

Commit

Permalink
Update hello.html
Browse files Browse the repository at this point in the history
  • Loading branch information
abraae authored Jun 28, 2024
1 parent 1a83546 commit c72de58
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions hello.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
let recorder;
let stream;
let recordedBlobs = [];
let recordingStartTime;

startRecordingButton.onclick = async () => {
stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
Expand All @@ -31,15 +30,14 @@
mimeType: 'video/webm;codecs=vp8',
timeSlice: 1000, // Record in slices of 1 second
ondataavailable: (blob) => {
recordedBlobs.push(blob);
if (recordedBlobs.length > 3) {
if (recordedBlobs.length === 3) {
recordedBlobs.shift(); // Keep only the last 3 seconds
}
recordedBlobs.push(blob);
}
});

recorder.startRecording();
recordingStartTime = Date.now();
startRecordingButton.disabled = true;
stopRecordingButton.disabled = false;
};
Expand All @@ -54,6 +52,7 @@
downloadLink.style.display = 'block';
video.srcObject = null;
video.src = url;
video.play();

stream.getTracks().forEach(track => track.stop());
startRecordingButton.disabled = false;
Expand Down

0 comments on commit c72de58

Please sign in to comment.