A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
fix: player size constraint is inconsistent and does not work universally
aminnausindb63dd0511c8
diff --git a/resources/js/components/video/PlayerBackdrop.vue b/resources/js/components/video/PlayerBackdrop.vueindex 62d7a0cb..70d394da 100644--- a/resources/js/components/video/PlayerBackdrop.vue+++ b/resources/js/components/video/PlayerBackdrop.vue@@ -2,14 +2,16 @@import type { HTMLAttributes } from 'vue';import { handleStorageURL } from '@/service/util';-import { computed, inject } from 'vue';+import { inject } from 'vue';import LazyImage from '@/components/lazy/LazyImage.vue';+const isAudio = inject<boolean>('isAudio');+const props = defineProps<{- isNormalView: boolean;isTheatreView: boolean;isVisible?: boolean;+ isPlayerSizeConstrained?: boolean; // (isAudio OR isPortrait) AND isNormalViewaspectRatio: {isPortrait: boolean;isAspectVideo: boolean;@@ -18,48 +20,42 @@ const props = defineProps<{posterUrl?: string;}>();-const isAudio = inject<boolean>('isAudio');--const audioPosterStyle = computed<HTMLAttributes['style']>(() => {- return {- backgroundImage: `url("${props.audioPosterUrl}")`,- backgroundPosition: 'center',- backgroundSize: 'cover',- backgroundRepeat: 'no-repeat',- };-});+const generatePosterStyle = (url?: string): HTMLAttributes['style'] => {+ if (!url) return {};-const videoPosterStyle = computed<HTMLAttributes['style']>(() => {return {- backgroundImage: `url("${props.posterUrl}")`,+ backgroundImage: `url("${url}")`,backgroundPosition: 'center',backgroundSize: 'cover',backgroundRepeat: 'no-repeat',};-});+};</script><template><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 size-full', { 'aspect-video': aspectRatio.isAspectVideo }, { relative: isVisible }]">+ <div v-if="isVisible" :class="['pointer-events-none z-3 size-full', { 'aspect-video': !isPlayerSizeConstrained }, { relative: isVisible }]"><template v-if="isAudio">- <div id="audio-poster" :class="['absolute inset-0 scale-105 blur-sm', { 'dark:scale-100': isNormalView }]" :style="audioPosterStyle"></div>+ <div+ id="audio-poster"+ :class="['absolute inset-0 scale-105 blur-sm', { 'dark:scale-100': isPlayerSizeConstrained }]"+ :style="generatePosterStyle(audioPosterUrl)"+ ></div><LazyImage:src="audioPosterUrl"alt="Album Art"wrapper-class="flex items-center justify-center"- :class="['mx-auto object-contain select-none md:h-screen', { 'max-h-[71vh]': isNormalView }, { 'max-h-screen': isTheatreView }]"+ :class="['mx-auto object-contain select-none md:h-screen', { 'max-h-[71vh]': isPlayerSizeConstrained }, { 'max-h-screen': isTheatreView }]"loading="eager"fetchpriority="high"/></template><div v-else class="contents">- <div id="thumbnail-blocker" class="absolute inset-0 scale-105 blur-sm" :style="videoPosterStyle"></div>+ <div id="thumbnail-blocker" class="absolute inset-0 scale-105 blur-sm" :style="generatePosterStyle(posterUrl)"></div><LazyImage:src="handleStorageURL(posterUrl) ?? ''"alt="Thumbnail"- :wrapper-class="[{ 'max-h-[71vh]': !aspectRatio.isAspectVideo && isNormalView }]"- :class="['mx-auto h-full object-contain']"+ :class="['mx-auto h-full object-contain', { 'max-h-[71vh]': isPlayerSizeConstrained }]"loading="eager"fetchpriority="high"/>diff --git a/resources/js/components/video/VideoPlayer.vue b/resources/js/components/video/VideoPlayer.vueindex b49b2978..3ed72c28 100755--- a/resources/js/components/video/VideoPlayer.vue+++ b/resources/js/components/video/VideoPlayer.vue@@ -145,6 +145,7 @@ const volumeChangeTimeout = ref<NodeJS.Timeout>();const autoSeekTimeout = ref<NodeJS.Timeout>();const timeDisplay = ref<'timeElapsed' | 'timeRemaining'>('timeElapsed');+const isPlayerSizeConstrained = computed(() => (isAudio.value || aspectRatio.value.isPortrait) && isNormalView.value); // Is size determined by album art or portrait videoconst isThumbnailDismissed = ref(false);const isPictureInPicture = ref(false);const isShowingControls = ref(false);@@ -1181,7 +1182,6 @@ defineExpose({audioPoster,viewMode,});-//#endregion</script>@@ -1190,13 +1190,7 @@ defineExpose({<div v-if="isTheatreView" class="pointer-events-none aspect-video w-full rounded-lg bg-black/30" /><div:class="- cn(- 'relative overflow-clip',- { 'theatre-mode player-transition animate-theatre-enter': isTheatreView },- { 'rounded-lg': isNormalView },- { 'rounded-sm': isFullScreen },- { 'max-h-[71vh]': isNormalView && !aspectRatio.isAspectVideo },- )+ cn('relative overflow-clip', { 'theatre-mode player-transition animate-theatre-enter': isTheatreView }, { 'rounded-lg': isNormalView }, { 'rounded-sm': isFullScreen })"ref="player-container"id="player-container"@@ -1210,7 +1204,7 @@ defineExpose({}">- <div :class="['z-3 flex h-full justify-center', { 'max-h-[71vh]': isNormalView && !aspectRatio.isAspectVideo }, { 'bg-black/10': isLoading }]">+ <div :class="['z-3 flex h-full justify-center', { 'bg-black/10': isLoading }]"><videoid="video-source"type="video/mp4"@@ -1221,9 +1215,9 @@ defineExpose({cn(`absolute h-full w-full object-contain select-none focus:outline-hidden`,{ 'static z-3': !isAudio && (!stateVideo.metadata?.poster_url || (stateVideo.metadata.poster_url && isThumbnailDismissed)) }, // Force position if no poster exists+ { 'bg-black': !isAudio && !aspectRatio.isAspectVideo }, // Black bg when video does not fill aspect-video{ 'aspect-video': !stateVideo.path }, // Default size before load is possible- (isAudio || aspectRatio.isPortrait) && isNormalView ? 'max-h-[71vh]' : 'aspect-video', // Force 16:9 for all non portrait video (reduces cls and uncertainty)- { 'bg-black/30': !isAudio && !aspectRatio.isAspectVideo },+ isPlayerSizeConstrained ? 'max-h-[71vh]' : 'aspect-video', // Force 16:9 for all non portrait video (reduces cls and uncertainty)isShowingControls ? 'cursor-auto' : 'cursor-none',isFullScreen || isTheatreView? '[--subtitle-cue-size:1.2rem] [--subtitle-font-size:180%]'@@ -1262,8 +1256,8 @@ defineExpose({:audio-poster-url="audioPoster":poster-url="stateVideo.metadata?.poster_url":is-visible="isAudio || isThumbnailVisible"- :is-normal-view="isNormalView":is-theatre-view="isTheatreView"+ :is-player-size-constrained="isPlayerSizeConstrained"/></div>