Skip to content

Commit

Permalink
video: Stop the recording if we get a clash in the video chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl committed Feb 21, 2024
1 parent 89e96b4 commit c575b27
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/stores/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,14 @@ export const useVideoStore = defineStore('video', () => {
activeStreams.value[streamName]!.mediaRecorder!.start(1000)
let chunksCount = 0
activeStreams.value[streamName]!.mediaRecorder!.ondataavailable = async (e) => {
await tempVideoChunksDB.setItem(`${recordingHash}_${chunksCount}`, e.data)
// Check first if this item is already in the database. If so, stop the recording and return.
const chunkName = `${recordingHash}_${chunksCount}`
const chunk = await tempVideoChunksDB.getItem(chunkName)
if (chunk) {
stopRecording(streamName)
return
}
await tempVideoChunksDB.setItem(chunkName, e.data)
chunksCount++
}

Expand Down

0 comments on commit c575b27

Please sign in to comment.