Skip to content

Commit

Permalink
feat: boot sequence only once
Browse files Browse the repository at this point in the history
  • Loading branch information
o-az committed Sep 27, 2024
1 parent 6478ef1 commit 5540e92
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions ceremony/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,49 +48,52 @@ $effect(() => {
document.getElementById("glitch-video").play()
}
})
let showBootSequence = $state(true)
let showBootSequence = $state(localStorage?.getItem("ceremony:show-boot-sequence") !== "false")
let bootSequenceVideoElement = $state<HTMLVideoElement | null>(null)
onMount(() => bootSequenceVideoElement?.play())
const hideBootSequenceVideo = () => (showBootSequence = false)
const hideBootSequenceVideo = () => {
showBootSequence = false
localStorage?.setItem("ceremony:show-boot-sequence", "false")
}
</script>

{#if showBootSequence}
<video
muted
autoplay
playsinline
data-video="bootsequence"
onended={hideBootSequenceVideo}
bind:this={bootSequenceVideoElement}
oncanplay={function() {
muted
autoplay
playsinline
data-video="bootsequence"
onended={hideBootSequenceVideo}
bind:this={bootSequenceVideoElement}
oncanplay={function() {
this.autoplay = true
}}
onloadeddata={function() {
onloadeddata={function() {
this.autoplay = true
}}
onloadedmetadata={function() {
onloadedmetadata={function() {
this.muted = true
}}
>
<source src="https://pub-32dd1494f0fa423cb1013941269ecce9.r2.dev/glitchboot.webm" type="video/webm" />
</video>
{:else}
<video
id="glitch-video"
loop
muted
autoplay
playsinline
data-video="glitch"
oncanplay={function() {
id="glitch-video"
loop
muted
autoplay
playsinline
data-video="glitch"
oncanplay={function() {
this.autoplay = true
}}
onloadeddata={function() {
onloadeddata={function() {
this.autoplay = true
}}
onloadedmetadata={function() {
onloadedmetadata={function() {
this.muted = true
}}
>
Expand All @@ -116,4 +119,4 @@ const hideBootSequenceVideo = () => (showBootSequence = false)
min-height: 100%;
object-fit: cover;
}
</style>
</style>

0 comments on commit 5540e92

Please sign in to comment.