A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
fix: can't play/pause player when clicking on blank space around am-lyrics
aminnausin90e084e50146
diff --git a/resources/js/components/video/plugins/lyrics/AmLyrics.vue b/resources/js/components/video/plugins/lyrics/AmLyrics.vueindex e78d1f3c..b294166c 100644--- a/resources/js/components/video/plugins/lyrics/AmLyrics.vue+++ b/resources/js/components/video/plugins/lyrics/AmLyrics.vue@@ -6,6 +6,8 @@ if (FLAGS.USE_AM_LYRICS) {await import('@aminnausin/am-lyrics/am-lyrics.js');}+const emit = defineEmits<{ play: [] }>();+const props = defineProps<{player: HTMLVideoElement | null;title?: string;@@ -18,10 +20,11 @@ const props = defineProps<{const amLyrics = useTemplateRef<HTMLElement & { currentTime: number }>('am-lyrics');const hasMounted = ref(false);-const hasStyled = ref(false);+let amLyricsContainer: HTMLElement | null = null;let amLyricsTimeUpdate: (() => void) | null = null;let amLyricsLineClick: ((e: Event) => void) | null = null;+let amLyricsContainerClick: ((e: MouseEvent) => void) | null = null;const initAmLyrics = async () => {const el = amLyrics.value;@@ -56,18 +59,45 @@ const destroyAmLyrics = () => {amLyricsTimeUpdate = null;amLyricsLineClick = null;++ if (amLyricsContainer && amLyricsContainerClick) {+ amLyricsContainer.removeEventListener('click', amLyricsContainerClick);+ }++ amLyricsContainer = null;+ amLyricsContainerClick = null;};const applyStyle = () => {- if (!amLyrics.value?.shadowRoot) return;- const style = document.createElement('style');- style.textContent = [- '.download-controls {margin-right: 20px !important; margin-top: -4px !important; align-items: start !important; height: 100% !important;}',- '.format-select {min-height: 20px !important;}',- '.download-button {height: 20px !important;}',- ].join('');- amLyrics.value.shadowRoot.appendChild(style);- hasStyled.value = true;+ const shadowRoot = amLyrics.value?.shadowRoot;+ if (!shadowRoot) return;++ if (!shadowRoot.querySelector('#am-lyrics-styles')) {+ const style = document.createElement('style');+ style.id = 'am-lyrics-styles';+ style.textContent = [+ '.download-controls { margin-right: 20px !important; margin-top: -4px !important; align-items: start !important; height: 100% !important; }',+ '.format-select { min-height: 20px !important; }',+ '.download-button { height: 20px !important; }',+ '.lyrics-line, .footer-content { pointer-events: auto !important; }',+ '.lyrics-footer { pointer-events: none !important; }',+ '.lyrics-container { pointer-events: auto !important; }',+ ].join('');+ shadowRoot.appendChild(style);+ }++ amLyricsContainer = shadowRoot.querySelector('.lyrics-container');+ if (!amLyricsContainer) return;++ amLyricsContainerClick = (e: MouseEvent) => {+ const target = e.target;++ if (!(target instanceof Element) || target.closest('.lyrics-line, .header-controls, .download-controls, .footer-content')) return;++ emit('play');+ };++ amLyricsContainer.addEventListener('click', amLyricsContainerClick);};watch(@@ -91,7 +121,7 @@ onUnmounted(() => {v-if="FLAGS.USE_AM_LYRICS && hasMounted"v-show="enabled"ref="am-lyrics"- class="pointer-events-auto! h-fit min-w-0 text-base"+ class="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.vueindex 8b984250..0221774a 100644--- a/resources/js/components/video/plugins/lyrics/LyricsMetadata.vue+++ b/resources/js/components/video/plugins/lyrics/LyricsMetadata.vue@@ -9,10 +9,13 @@ 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 v-if="media.metadata?.poster_image?.path" class="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 @min-[2048px]:max-w-lg"- :style="{ animation: 'spin 10s linear infinite', animationPlayState: isPaused ? 'paused' : 'running' }"+ class="pointer-events-auto relative max-w-72 cursor-pointer overflow-clip rounded-full 2xl:max-w-96 @min-[2048px]:max-w-lg"+ :style="{+ animation: 'spin 10s linear infinite',+ animationPlayState: isPaused ? 'paused' : 'running',+ }"@click="emit('play')"><BlurhashImage@@ -30,14 +33,14 @@ const emit = defineEmits<{ play: [] }>();<div class="size-[16%] rounded-full ring-2"></div></div></div>- <div class="space-y-1 p-4 text-left">+ <div class="media-info space-y-1 p-4 text-left"><div class="flex items-start gap-2"><h3 class="line-clamp-2 text-xl text-shadow-xs">{{ media.title }}</h3><div class="flex h-7 flex-1 items-center gap-1 *:pointer-events-none *:text-xs *:shadow-xs"><MediaTag class="text-foreground-1 dark:text-foreground-4 h-5">{{ media.metadata.codec }}</MediaTag>- <MediaTag v-if="media.metadata.bitrate && media.metadata.codec === 'mp3'" class="3xl:block text-foreground-1 dark:text-foreground-4 hidden h-5"- >{{ media.metadata.bitrate / 1000 }}kbps</MediaTag- >+ <MediaTag v-if="media.metadata.bitrate && media.metadata.codec === 'mp3'" class="3xl:block text-foreground-1 dark:text-foreground-4 hidden h-5">+ {{ media.metadata.bitrate / 1000 }}kbps+ </MediaTag></div></div><p class="truncate text-sm text-shadow-xs">@@ -49,3 +52,9 @@ const emit = defineEmits<{ play: [] }>();</div></div></template>+<style lang="css" scoped>+h3,+.media-info > p {+ pointer-events: auto;+}+</style>diff --git a/resources/js/components/video/plugins/lyrics/VideoLyrics.vue b/resources/js/components/video/plugins/lyrics/VideoLyrics.vueindex 862233ad..f511b4c9 100644--- a/resources/js/components/video/plugins/lyrics/VideoLyrics.vue+++ b/resources/js/components/video/plugins/lyrics/VideoLyrics.vue@@ -281,6 +281,7 @@ defineExpose({ scrollToCurrent });:album="stateVideo.album":lyrics="stateVideo.metadata?.lyrics":duration="timeDuration"+ @play="emit('play')"/><template #fallback><p class="animate-pulse px-4 pt-10 text-xl">...</p> </template></Suspense>