Skip to content

Commit a30d5e7

Browse files
authored
chore: add auto timestamp diff detection at live video (#21936)
1 parent f42b908 commit a30d5e7

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

docs/.vitepress/theme/live/Layout.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Footer from '@components/oss/Footer.vue'
1414
<Timer at="2026-03-19T15:00:00.000Z" />
1515
</template>
1616
<template #timeout>
17-
<VideoIframe />
17+
<VideoIframe at="2026-03-19T15:00:00.000Z" />
1818
</template>
1919
</TimeoutSwitcher>
2020
<Events />

docs/.vitepress/theme/live/VideoIframe.vue

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,39 @@
1+
<script setup>
2+
import { computed } from 'vue'
3+
4+
const props = defineProps({
5+
at: {
6+
type: String,
7+
required: true,
8+
},
9+
})
10+
11+
const iframeSrc = computed(() => {
12+
const totalLength = 39 * 60 + 15 // 39 minutes and 15 seconds
13+
const atTime = new Date(props.at).getTime()
14+
const now = Date.now()
15+
const elapsedSeconds = Math.max(0, Math.floor((now - atTime) / 1000))
16+
17+
const params = new URLSearchParams({
18+
si: 'hhgR4fwkRw9zQ0yx',
19+
controls: '0',
20+
start: elapsedSeconds > totalLength ? 0 : String(elapsedSeconds),
21+
disablekb: '1',
22+
rel: '0',
23+
autoplay: '1',
24+
})
25+
26+
return `https://www.youtube-nocookie.com/embed/bmWQqAKLgT4?${params.toString()}`
27+
})
28+
</script>
29+
130
<template>
231
<div class="wrapper wrapper--ticks w-full border-nickel border-t md:divide-x">
332
<iframe
433
width="560"
534
height="315"
635
class="w-full h-auto max-h-[calc(100vh-5rem-var(--vp-banner-height,0px))] aspect-video"
7-
src="https://www.youtube-nocookie.com/embed/bmWQqAKLgT4?si=hhgR4fwkRw9zQ0yx&amp;controls=0&amp;start=0&amp;disablekb=1&amp;rel=0&amp;autoplay=1"
36+
:src="iframeSrc"
837
title="YouTube video player"
938
frameborder="0"
1039
allow="

0 commit comments

Comments
 (0)