Skip to content

Commit

Permalink
fix: unloading of videos
Browse files Browse the repository at this point in the history
  • Loading branch information
kurozenzen committed May 28, 2023
1 parent 6674a20 commit 734289a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/lib/player/Player.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,16 @@
displayVideo = true
} else {
if (video) {
video.src = ''
playing = false
loading = false
video.addEventListener('error', () => (displayVideo = false), { once: true })
video.addEventListener(
'error',
() => {
displayVideo = false
},
{ once: true }
)
video.src = ''
}
}
}
Expand All @@ -62,11 +68,6 @@
$: playing = displayVideo && playing
$: paused = !playing
$: percent = (currentTime / duration) * 98 + 1
$: {
if (video && displayVideo) {
video.src = src
}
}
const formatDuration = (time) => {
const floored = Math.floor(time)
Expand Down Expand Up @@ -108,6 +109,7 @@
bind:paused
bind:currentTime
bind:duration
{src}
/>
<span class:play={playing}>{formatDuration(timeLeft)}</span>
<input
Expand Down Expand Up @@ -135,6 +137,7 @@
video {
width: 100%;
grid-area: 1/1/4/4;
contain: strict;
}
.player :global(.center) {
Expand Down

0 comments on commit 734289a

Please sign in to comment.