Skip to content

A self-hosted media server and file management system

feat: use server based intro timings

aminnausinfc5d219a0aae
diff --git a/resources/js/components/video/PlayerSkipIntro.vue b/resources/js/components/video/PlayerSkipIntro.vue
index 74380e82..eff3792b 100644
--- a/resources/js/components/video/PlayerSkipIntro.vue
+++ b/resources/js/components/video/PlayerSkipIntro.vue
@@ -1,7 +1,8 @@
<script setup lang="ts">
-import { FormNumberField } from '@/components/cedar-ui/number-field';
-import { computed, ref } from 'vue';
+import { useContentStore } from '@/stores/ContentStore';
+import { storeToRefs } from 'pinia';
import { ButtonText } from '@/components/cedar-ui/button';
+import { computed } from 'vue';
import ProiconsFastForward from '~icons/proicons/fast-forward';
@@ -10,14 +11,22 @@ const props = defineProps<{
handleAutoSeek: (seconds: number) => void;
timeElapsed: number;
timeDuration: number;
+ isNormalView: boolean;
}>();
-const introStart = ref(0);
-const introDuration = ref(90);
+const { stateVideo, stateFolder } = storeToRefs(useContentStore());
const currentTime = computed(() => (props.timeElapsed * props.timeDuration) / 100); // This is pre-optimised because timeElapsed does not change if controls are not showing which is cool
+const introDuration = computed(() => stateVideo.value.intro_duration ?? stateFolder.value.series?.avg_intro_duration);
+const introStart = computed(() => stateVideo.value.intro_start);
const intro = computed(() => {
+ if (!introStart.value || !introDuration.value)
+ return {
+ isActive: false,
+ timeRemaining: 0,
+ };
+
const current = currentTime.value;
const start = introStart.value;
const end = start + introDuration.value;
@@ -29,22 +38,15 @@ const intro = computed(() => {
});
</script>
<template>
- <div class="text-foreground-0 pointer-events-auto absolute top-2 left-2 flex flex-col gap-2" style="z-index: 10">
- <FormNumberField :field="{ name: 'introStart', type: 'number', min: 0, default: 0 }" v-model="introStart" />
- <FormNumberField :field="{ name: 'introEnd', type: 'number', min: 0, default: 90 }" v-model="introDuration" />
- <p class="bg-surface-0 text-foreground-0 p-1">{{ currentTime }}</p>
- </div>
- <Transition
- enter-active-class="ease-out"
- enter-from-class="opacity-0"
- enter-to-class="opacity-100"
- leave-active-class="ease-in"
- leave-from-class="opacity-100"
- leave-to-class="opacity-0"
- >
- <div class="absolute bottom-22 left-2 transition-opacity duration-300" v-cloak v-show="intro.isActive" style="z-index: 7">
+ <Transition enter-from-class="opacity-0" enter-to-class="opacity-100" leave-from-class="opacity-100" leave-to-class="opacity-0">
+ <div
+ :class="['absolute bottom-22 transition-opacity duration-200 ease-in-out', isNormalView ? 'left-2' : 'left-4']"
+ v-cloak
+ v-show="intro.isActive && isShowingControls"
+ style="z-index: 7"
+ >
<ButtonText
- class="text-foreground-0 pointer-events-auto ring-0 backdrop-blur-xs select-none dark:bg-neutral-900/60"
+ class="text-foreground-0 pointer-events-auto bg-neutral-900/60 ring-0 backdrop-blur-xs select-none"
@click="
() => {
handleAutoSeek(intro.timeRemaining);
diff --git a/resources/js/components/video/VideoPlayer.vue b/resources/js/components/video/VideoPlayer.vue
index 0dbc4828..f93ab512 100755
--- a/resources/js/components/video/VideoPlayer.vue
+++ b/resources/js/components/video/VideoPlayer.vue
@@ -1295,6 +1295,7 @@ defineExpose({
:time-duration="timeDuration"
:time-elapsed="timeElapsed"
:handle-auto-seek="handleAutoSeek"
+ :is-normal-view="isNormalView"
/>
<!-- Controls (Z-7) -->