Skip to content

Commit 2b1323d

Browse files
author
yashdesu
committed
feat: minor fixes
1 parent 7072d07 commit 2b1323d

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/ui/svelte/VideoFetch.svelte

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@
165165
mp4boxfile.flush()
166166
maybeEndOfStream()
167167
// Start playback after all data is processed
168-
videoElement.play().catch((e) => console.error('Play error:', e))
168+
if (!isControlled) {
169+
togglePlay()
170+
}
169171
return
170172
}
171173
@@ -217,15 +219,19 @@
217219
}
218220
219221
function togglePlay() {
220-
if (videoElement.value?.paused) {
221-
videoElement.value
222+
if (!videoElement) {
223+
return
224+
}
225+
226+
if (videoElement?.paused) {
227+
videoElement
222228
?.play()
223229
.then(() => {
224230
isPaused = false
225231
})
226232
.catch((e) => console.error('Play error:', e))
227233
} else {
228-
videoElement.value?.pause()
234+
videoElement?.pause()
229235
isPaused = true
230236
}
231237
}

src/ui/vue/VideoFetch.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,10 @@ function downloadChunk() {
173173
if (nextRangeStart >= totalFileSize) {
174174
mp4boxfile.flush()
175175
maybeEndOfStream()
176-
// Start playback after all data is processed
177-
videoElement.value?.play().catch((e) => console.error('Play error:', e))
176+
if (!props.isControlled) {
177+
// If controlled, then it will play when clicked.
178+
togglePlay()
179+
}
178180
return
179181
}
180182
@@ -224,6 +226,10 @@ function maybeEndOfStream() {
224226
}
225227
226228
function togglePlay() {
229+
if (!videoElement.value) {
230+
return
231+
}
232+
227233
if (videoElement.value?.paused) {
228234
videoElement.value
229235
?.play()

0 commit comments

Comments
 (0)