A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
feat: add optional metadata to the side of lyrics
aminnausin869144eae639
diff --git a/resources/js/components/lazy/BlurhashImage.vue b/resources/js/components/lazy/BlurhashImage.vueindex 9f9152ca..e2084cbd 100644--- a/resources/js/components/lazy/BlurhashImage.vue+++ b/resources/js/components/lazy/BlurhashImage.vue@@ -19,6 +19,7 @@ const props = withDefaults(animate?: boolean;blurhash?: string;rootMargin?: string;+ style?: HTMLAttributes['style'];}>(),{rootMargin: '144px',@@ -129,7 +130,15 @@ onBeforeUnmount(() => {</script><template><div ref="imageContainer" :class="cn('relative block h-full w-full', wrapperClass)">- <canvas v-if="blurhash" ref="canvas" v-show="!isError" :class="cn('absolute inset-0 z-0 h-full w-full object-cover', $attrs.class)" aria-hidden="true" tabindex="-1" />+ <canvas+ v-if="blurhash"+ ref="canvas"+ v-show="!isError"+ :class="cn('absolute inset-0 z-0 h-full w-full object-cover', $attrs.class)"+ aria-hidden="true"+ tabindex="-1"+ :style="style"+ /><div v-else v-show="src && isLoading && !isError" class="absolute inset-0 flex items-center justify-center"><SvgSpinners90RingWithBg class="size-4" /></div>@@ -143,6 +152,7 @@ onBeforeUnmount(() => {:alt="isError || !isLoaded ? '' : alt":src="activeSrc":class="['lazy-image relative', { 'lazy-image transition-opacity duration-300 ease-in-out': animate }, { loaded: isLoaded }]"+ :style="style"@load="isLoading = false;isError = false;diff --git a/resources/js/components/video/VideoPlayer.vue b/resources/js/components/video/VideoPlayer.vueindex 5d746400..f5ed9319 100755--- a/resources/js/components/video/VideoPlayer.vue+++ b/resources/js/components/video/VideoPlayer.vue@@ -133,6 +133,7 @@ const {isAudioGraphEnabled,showAutoSubtitles,showSeekButtons,+ showLyricsMetadata,useAmLyrics,} = storeToRefs(useAppStore());const { setContextMenu, closeContextMenu } = useAppStore();@@ -332,6 +333,16 @@ const playerContextMenuItems = computed<ContextMenuItem[]>(() =>togglePictureInPicture();},},+ {+ text: 'Show Metadata',+ icon: showLyricsMetadata.value ? ProiconsCheckmark : undefined,+ selected: showLyricsMetadata.value,+ hidden: !isAudio.value || !isShowingLyrics.value,+ disabled: !stateVideo.value.metadata?.poster_image?.path,+ action: () => {+ showLyricsMetadata.value = !showLyricsMetadata.value;+ },+ },{text: 'Use AM-Lyrics',icon: useAmLyrics.value ? ProiconsCheckmark : undefined,@@ -1893,14 +1904,15 @@ defineExpose({><div :class="`flex size-full opacity-0 transition-[opacity,translate] duration-300`" v-show="isShowingLyrics"><VideoLyrics- ref="player-lyrics"v-if="isAudio || stateFolder.is_majority_audio"- @seek="handleManualSeek"+ ref="player-lyrics":player="player":raw-lyrics="stateVideo?.metadata?.lyrics ?? ''":time-duration="timeDuration":is-paused="isPaused":is-showing-lyrics="isShowingLyrics"+ @seek="handleManualSeek"+ @play="handlePlayerToggle"/></div></Transition>diff --git a/resources/js/components/video/plugins/lyrics/AmLyrics.vue b/resources/js/components/video/plugins/lyrics/AmLyrics.vueindex e12a42dd..5ff2cdd7 100644--- a/resources/js/components/video/plugins/lyrics/AmLyrics.vue+++ b/resources/js/components/video/plugins/lyrics/AmLyrics.vue@@ -90,7 +90,7 @@ onUnmounted(() => {v-if="FLAGS.USE_AM_LYRICS && hasMounted"v-show="enabled"ref="am-lyrics"- class="pointer-events-auto! h-full w-full text-base"+ class="pointer-events-auto! h-fit min-w-0 text-base":song-title="title":song-artist="artist":song-album="album"diff --git a/resources/js/components/video/plugins/lyrics/LyricsMetadata.vue b/resources/js/components/video/plugins/lyrics/LyricsMetadata.vuenew file mode 100644index 00000000..7f2a678e--- /dev/null+++ b/resources/js/components/video/plugins/lyrics/LyricsMetadata.vue@@ -0,0 +1,49 @@+<script setup lang="ts">+import type { VideoResource } from '@/contracts/media';++import BlurhashImage from '@/components/lazy/BlurhashImage.vue';+import MediaTag from '@/components/labels/MediaTag.vue';++defineProps<{ media: VideoResource; isPaused: boolean }>();++const emit = defineEmits<{ play: [] }>();+</script>+<template>+ <div v-if="media.metadata?.poster_image?.path" class="pointer-events-auto h-full min-w-0 flex-col justify-center gap-6 p-8">+ <div+ class="relative max-w-72 cursor-pointer 2xl:max-w-96"+ :style="{ animation: 'spin 10s linear infinite', animationPlayState: isPaused ? 'paused' : 'running' }"+ @click="emit('play')"+ >+ <BlurhashImage+ class="aspect-square size-full rounded-full object-cover object-top"+ alt="Album Art"+ :wrapper-class="'aspect-square size-full'"+ :blurhash="media.metadata.poster_image.blur_hash"+ :src="media.metadata.poster_image.path"+ :style="{+ maskImage: 'radial-gradient(circle, transparent 0 10%, black 10.5% 100%)',+ WebkitMaskImage: 'radial-gradient(circle, transparent 0 10%, black 10.5% 100%)',+ }"+ />+ <div class="absolute inset-0 z-4 flex items-center justify-center">+ <div class="size-[16%] rounded-full ring-2"></div>+ </div>+ </div>+ <div class="space-y-1 p-4 text-left">+ <div class="flex items-start gap-2">+ <h3 class="line-clamp-2 text-xl">{{ media.title }}</h3>+ <div class="flex h-7 flex-1 items-center gap-1 *:pointer-events-none *:text-xs">+ <MediaTag class="h-5">{{ media.metadata.codec }}</MediaTag>+ <MediaTag v-if="media.metadata.bitrate && media.metadata.codec === 'mp3'" class="3xl:block hidden h-5">{{ media.metadata.bitrate / 1000 }}kbps</MediaTag>+ </div>+ </div>+ <p class="truncate text-sm text-white/80">+ {{ media.artist }}+ </p>+ <p class="truncate text-sm text-white/50">+ {{ media.album }}+ </p>+ </div>+ </div>+</template>diff --git a/resources/js/components/video/plugins/lyrics/VideoLyrics.vue b/resources/js/components/video/plugins/lyrics/VideoLyrics.vueindex 950e72b2..44145e34 100644--- a/resources/js/components/video/plugins/lyrics/VideoLyrics.vue+++ b/resources/js/components/video/plugins/lyrics/VideoLyrics.vue@@ -9,19 +9,21 @@ import { useAppStore } from '@/stores/AppStore';import { storeToRefs } from 'pinia';import { onSeek } from '@/service/player/seekBus';import { FLAGS } from '@/config/featureFlags';+import { cn } from '@aminnausin/cedar-ui';import PlayerToolbarButton from '@/components/video/button/PlayerToolbarButton.vue';import VideoLyricItem from '@/components/video/plugins/lyrics/VideoLyricItem.vue';+import LyricsMetadata from '@/components/video/plugins/lyrics/LyricsMetadata.vue';import AmLyrics from '@/components/video/plugins/lyrics/AmLyrics.vue';let unsubscribe: () => boolean;const { stateLyrics, dirtyLyric, isLoadingLyrics } = storeToRefs(useLyricStore());const { handleGenerateLyrics, handleOpenLyricsModal } = useLyricStore();-const { useAmLyrics } = storeToRefs(useAppStore());+const { useAmLyrics, showLyricsMetadata } = storeToRefs(useAppStore());const { stateVideo } = storeToRefs(useContentStore());-const emit = defineEmits<{ seek: [value: number] }>();+const emit = defineEmits<{ seek: [value: number]; play: [] }>();const props = defineProps<{ rawLyrics: string; player: HTMLVideoElement | null; timeDuration: number; isPaused: boolean; isShowingLyrics: boolean }>();const activeLyricElement = ref<HTMLElement | null>(null);@@ -254,56 +256,64 @@ watch(defineExpose({ scrollToCurrent });</script><template>- <Suspense v-if="FLAGS.USE_AM_LYRICS">- <AmLyrics- :enabled="useAmLyrics && isShowingLyrics"- :player="player"- :title="stateVideo.title"- :artist="stateVideo.artist"- :album="stateVideo.album"- :duration="timeDuration"- />- <template #fallback><p class="animate-pulse px-4 pt-10 text-xl">...</p> </template>- </Suspense>- <section- class="fade-mask font-lyrics scrollbar-hide flex h-full w-full flex-col overflow-y-scroll text-center text-sm sm:text-lg 2xl:text-xl"- ref="lyrics-container"- v-show="lyrics.length > 0 && !useAmLyrics"- @wheel="handleUserScroll"- @touchmove="handleUserScroll"- >- <div class="shrink-0" style="height: 45%"></div>- <VideoLyricItem- v-for="(lyric, index) in lyrics"- v-show="lyric.time || lyric.text.trim().length != 0"- :key="index"- :lyric="lyric"- :index="index"- :is-active="lyric.time === activeTime"- :distance="lyrics.length === 1 && lyrics[0].text === 'No lyrics yet...' ? undefined : activeIndex < 0 ? Infinity : Math.abs(index - activeIndex)"- :title="`${lyric.time}s`"- :is-blur-enabled="useFocusedScroll && isFocusedScroll && activeIndex >= 0"- @clicked="lyric.time !== undefined ? handleClick(`lyric-${lyric.time}`, lyric.time) : null"- />- <VideoLyricItem- v-if="lyrics.length === 1 && lyrics[0].text === 'No lyrics yet...'"- :lyric="{ text: `${isLoadingLyrics ? 'Generating' : 'Generate with Magic'}...` }"- :is-active="false"- :index="0"- :class="[isLoadingLyrics ? '*:cursor-wait!' : 'hocus:text-yellow-500 *:cursor-pointer!']"- @clicked="handleGenerateLyrics"- />- <div class="shrink-0" style="height: 45%"></div>- </section>- <template v-if="!useAmLyrics">- <div class="pointer-events-auto absolute top-0 right-0 left-0 h-12" style="z-index: 6"></div>- <div class="pointer-events-auto absolute right-0 bottom-0 left-0 h-16" style="z-index: 6"></div>- </template>- <Teleport defer to="#player-toolbar" v-if="isShowingLyrics">- <PlayerToolbarButton v-if="!useAmLyrics" @click="handleOpenLyricsModal" title="Edit lyrics" :is-active="!!dirtyLyric">- {{ dirtyLyric ? 'preview' : 'edit' }}- </PlayerToolbarButton>- </Teleport>+ <div :class="cn('pointer-events-none h-full w-full gap-4', { 'lg:grid-cols[3fr_5fr] lg:grid 2xl:grid-cols-[2fr_5fr]': showLyricsMetadata })">+ <LyricsMetadata v-show="showLyricsMetadata" :media="stateVideo" :is-paused="isPaused" @play="emit('play')" class="hidden 2xl:flex" />+ <Suspense v-if="FLAGS.USE_AM_LYRICS">+ <AmLyrics+ :enabled="useAmLyrics && isShowingLyrics"+ :player="player"+ :title="stateVideo.title"+ :artist="stateVideo.artist"+ :album="stateVideo.album"+ :duration="timeDuration"+ />+ <template #fallback><p class="animate-pulse px-4 pt-10 text-xl">...</p> </template>+ </Suspense>++ <section+ :class="+ cn('fade-mask font-lyrics scrollbar-hide flex h-full w-full flex-col overflow-y-scroll text-center text-sm sm:text-lg 2xl:text-xl', {+ 'fade-mask-left': showLyricsMetadata,+ })+ "+ ref="lyrics-container"+ v-show="lyrics.length > 0 && !useAmLyrics"+ @wheel="handleUserScroll"+ @touchmove="handleUserScroll"+ >+ <div class="shrink-0" style="height: 45%"></div>+ <VideoLyricItem+ v-for="(lyric, index) in lyrics"+ v-show="lyric.time || lyric.text.trim().length != 0"+ :key="index"+ :lyric="lyric"+ :index="index"+ :is-active="lyric.time === activeTime"+ :distance="lyrics.length === 1 && lyrics[0].text === 'No lyrics yet...' ? undefined : activeIndex < 0 ? Infinity : Math.abs(index - activeIndex)"+ :title="`${lyric.time}s`"+ :is-blur-enabled="useFocusedScroll && isFocusedScroll && activeIndex >= 0"+ @clicked="lyric.time !== undefined ? handleClick(`lyric-${lyric.time}`, lyric.time) : null"+ />+ <VideoLyricItem+ v-if="lyrics.length === 1 && lyrics[0].text === 'No lyrics yet...'"+ :lyric="{ text: `${isLoadingLyrics ? 'Generating' : 'Generate with Magic'}...` }"+ :is-active="false"+ :index="0"+ :class="[isLoadingLyrics ? '*:cursor-wait!' : 'hocus:text-yellow-500 *:cursor-pointer!']"+ @clicked="handleGenerateLyrics"+ />+ <div class="shrink-0" style="height: 45%"></div>+ </section>+ <template v-if="!useAmLyrics">+ <div class="pointer-events-auto absolute top-0 right-0 left-0 h-12" style="z-index: 6"></div>+ <div class="pointer-events-auto absolute right-0 bottom-0 left-0 h-16" style="z-index: 6"></div>+ </template>+ <Teleport defer to="#player-toolbar" v-if="isShowingLyrics">+ <PlayerToolbarButton v-if="!useAmLyrics" @click="handleOpenLyricsModal" title="Edit lyrics" :is-active="!!dirtyLyric">+ {{ dirtyLyric ? 'preview' : 'edit' }}+ </PlayerToolbarButton>+ </Teleport>+ </div></template><style lang="css" scoped>@@ -322,4 +332,12 @@ defineExpose({ scrollToCurrent });-webkit-mask-size: 100% 100%;-webkit-mask-repeat: no-repeat;}++.fade-mask-left {+ mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 90%, transparent 100%), linear-gradient(to right, transparent 0%, black 2%, black 100%);+ mask-composite: intersect;++ -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 90%, transparent 100%), linear-gradient(to right, transparent 0%, black 2%, black 100%);+ -webkit-mask-composite: source-in;+}</style>diff --git a/resources/js/stores/AppStore.ts b/resources/js/stores/AppStore.tsindex 6abc868e..31bff881 100644--- a/resources/js/stores/AppStore.ts+++ b/resources/js/stores/AppStore.ts@@ -81,6 +81,7 @@ export const useAppStore = defineStore('App', () => {const isAmbientMode = usePersisted('ambientMode', false);const showModernUI = usePersisted('showModernUI', true);+ const showLyricsMetadata = usePersisted('showLyricsMetadata', false);const useAmLyrics = usePersisted('useAmLyrics', false);const preferredAudioLanguage = usePersistedString('preferredAudioLanguage', '');@@ -184,6 +185,7 @@ export const useAppStore = defineStore('App', () => {isPlaylist.init();isAmbientMode.init();+ showLyricsMetadata.init();useAmLyrics.init();preferredAudioLanguage.init();@@ -202,6 +204,7 @@ export const useAppStore = defineStore('App', () => {watch(isAmbientMode.state, isAmbientMode.persist);watch(isPlaylist.state, isPlaylist.persist);+ watch(showLyricsMetadata.state, showLyricsMetadata.persist);watch(useAmLyrics.state, useAmLyrics.persist);watch(preferredAudioLanguage.state, preferredAudioLanguage.persist);@@ -219,6 +222,7 @@ export const useAppStore = defineStore('App', () => {showAutoSubtitles: showAutoSubtitles.state,showSeekButtons: showSeekButtons.state,preferredAudioLanguage: preferredAudioLanguage.state,+ showLyricsMetadata: showLyricsMetadata.state,useAmLyrics: useAmLyrics.state,initBrowserState,