Skip to content

A self-hosted media server and file management system

fix: video thumbnail shows video behind it if not the same size, and does not fade out

aminnausin25697901c360
diff --git a/resources/js/components/video/PlayerBackdrop.vue b/resources/js/components/video/PlayerBackdrop.vue
index f42d6e64..258bfb3e 100644
--- a/resources/js/components/video/PlayerBackdrop.vue
+++ b/resources/js/components/video/PlayerBackdrop.vue
@@ -8,15 +8,13 @@ import LazyImage from '@/components/lazy/LazyImage.vue';
const props = defineProps<{
isNormalView: boolean;
+ isVisible?: boolean;
aspectRatio: {
isPortrait: boolean;
isAspectVideo: boolean;
};
- isThumbnailDismissed?: boolean;
audioPosterUrl: string;
posterUrl?: string;
- isLoading?: boolean;
- isVisible?: boolean;
}>();
const isAudio = inject<boolean>('isAudio');
@@ -29,52 +27,41 @@ const audioPosterStyle = computed<HTMLAttributes['style']>(() => {
backgroundRepeat: 'no-repeat',
};
});
+
+const videoPosterStyle = computed<HTMLAttributes['style']>(() => {
+ return {
+ backgroundImage: `url("${props.posterUrl}")`,
+ backgroundPosition: 'center',
+ backgroundSize: 'cover',
+ backgroundRepeat: 'no-repeat',
+ };
+});
</script>
<template>
- <!-- <LazyImage :src="audioPosterUrl" alt="Album Art" class="mx-auto h-full max-h-full max-w-full object-contain select-none" loading="eager" fetchpriority="high" /> -->
- <!-- <img :src="audioPosterUrl" class="mx-auto h-full max-h-[71vh] min-h-[56.25cqw] object-cover" /> -->
- <div
- v-if="isVisible"
- :class="[
- 'pointer-events-none relative z-3',
- // (isAudio || aspectRatio.isPortrait) && isNormalView ? 'min-h-[56.25cqw]' : 'aspect-video',
- // isAudio && !isLoading ? 'min-h-[56.25cqw]' : 'absolute inset-0',
- // 'absolute inset-0',
- { 'aspect-video': aspectRatio.isAspectVideo },
- ]"
- >
- <template v-if="isAudio">
- <div id="audio-poster" class="absolute inset-0 -z-10 scale-105 blur-sm dark:scale-100" :style="audioPosterStyle"></div>
- <!-- <img :src="audioPosterUrl" :class="['mx-auto h-screen object-contain select-none', { 'max-h-[71vh]': isNormalView }]" /> -->
- <LazyImage
- :src="audioPosterUrl"
- alt="Album Art"
- :class="['mx-auto h-screen object-contain select-none', { 'max-h-[71vh]': isNormalView }]"
- loading="eager"
- fetchpriority="high"
- />
- <!-- <img :src="audioPosterUrl" class="mx-auto h-full max-h-[71vh] min-h-[56.25cqw] object-cover" /> -->
- </template>
- <!-- <img v-show="!isAudio && posterUrl && !isThumbnailDismissed" :src="handleStorageURL(posterUrl) ?? ''" class="mx-auto h-full max-h-[71vh] min-h-[56.25cqw] object-cover" /> -->
- <!-- <img
- v-if="!isAudio && posterUrl && !isThumbnailDismissed"
- :src="handleStorageURL(posterUrl) ?? ''"
- :class="['z-3 mx-auto h-full object-cover', { 'max-h-[71vh]': !aspectRatio.isAspectVideo && isNormalView }]"
- /> -->
- <LazyImage
- v-show="!isAudio && posterUrl && !isThumbnailDismissed"
- :src="handleStorageURL(posterUrl) ?? ''"
- alt="Thumbnail"
- :wrapper-class="[{ 'max-h-[71vh]': !aspectRatio.isAspectVideo && isNormalView }]"
- :class="['z-3 mx-auto h-full object-cover']"
- loading="eager"
- fetchpriority="high"
- />
- </div>
+ <Transition leave-from-class="opacity-100" leave-to-class="opacity-0" leave-active-class="absolute! inset-0 duration-700 transition-opacity ease-in-out">
+ <div v-if="isVisible" :class="['pointer-events-none z-3', { 'aspect-video': aspectRatio.isAspectVideo }, { relative: isVisible }]">
+ <template v-if="isAudio">
+ <div id="audio-poster" class="absolute inset-0 -z-10 scale-105 blur-sm dark:scale-100" :style="audioPosterStyle"></div>
+ <LazyImage
+ :src="audioPosterUrl"
+ alt="Album Art"
+ :class="['mx-auto object-contain select-none md:h-screen', { 'max-h-[71vh]': isNormalView }]"
+ loading="eager"
+ fetchpriority="high"
+ />
+ </template>
+ <div v-else class="contents">
+ <div id="thumbnail-blocker" class="absolute inset-0 -z-10 scale-105 blur-sm dark:scale-100" :style="videoPosterStyle"></div>
+ <LazyImage
+ :src="handleStorageURL(posterUrl) ?? ''"
+ alt="Thumbnail"
+ :wrapper-class="[{ 'max-h-[71vh]': !aspectRatio.isAspectVideo && isNormalView }]"
+ :class="['z-3 mx-auto h-full object-cover']"
+ loading="eager"
+ fetchpriority="high"
+ />
+ </div>
+ </div>
+ </Transition>
</template>
-<style lang="css" scoped>
-.poster-container {
- --width: calc();
-}
-</style>
diff --git a/resources/js/components/video/VideoPlayer.vue b/resources/js/components/video/VideoPlayer.vue
index 79398d5a..b5e35e6b 100755
--- a/resources/js/components/video/VideoPlayer.vue
+++ b/resources/js/components/video/VideoPlayer.vue
@@ -166,6 +166,8 @@ const isFullScreen = computed(() => viewMode.value == 'fullscreen');
const isTheatreView = computed(() => viewMode.value === 'theatre');
const isNormalView = computed(() => viewMode.value === 'normal');
+const isThumbnailVisible = computed(() => !!stateVideo.value.metadata?.poster_url && !isThumbnailDismissed.value);
+
// Player Info
const endsAtTime = ref('00:00');
const bufferTime = ref<number>(0);
@@ -1208,7 +1210,7 @@ defineExpose({
{ 'static z-3': !isAudio && (!stateVideo.metadata?.poster_url || (stateVideo.metadata.poster_url && isThumbnailDismissed)) }, // Force position if no poster exists
{ 'aspect-video': !stateVideo.path || aspectRatio.isAspectVideo }, // Default size before load is possible
{ 'max-h-[71vh]': aspectRatio.isPortrait && isNormalView },
- { 'bg-black': !isAudio && !aspectRatio.isAspectVideo },
+ { 'bg-black/30': !isAudio && !aspectRatio.isAspectVideo },
isShowingControls ? 'cursor-auto' : 'cursor-none',
isFullScreen || isTheatreView
? '[--subtitle-cue-size:1.2rem] [--subtitle-font-size:180%]'
@@ -1246,9 +1248,8 @@ defineExpose({
:aspect-ratio="aspectRatio"
:audio-poster-url="audioPoster"
:poster-url="stateVideo.metadata?.poster_url"
- :is-thumbnail-dismissed="isThumbnailDismissed"
+ :is-visible="isAudio || isThumbnailVisible"
:is-normal-view="isNormalView"
- :is-visible="isAudio || (!!stateVideo.metadata?.poster_url && !isThumbnailDismissed)"
/>
</div>