A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
feat: add optional am-lyric component
aminnausin006e334d5b9d
diff --git a/package-lock.json b/package-lock.jsonindex 2559b751..463072a7 100755--- a/package-lock.json+++ b/package-lock.json@@ -7,6 +7,7 @@"dependencies": {"@jellyfin/libass-wasm": "4.2.3","@tanstack/vue-query": "^5.77.2",+ "@uimaxbai/am-lyrics": "^1.6.0","@vueuse/components": "^13.0.0","@vueuse/core": "^13.0.0","@vueuse/integrations": "^13.0.0",@@ -180,6 +181,15 @@"node": ">=6.0.0"}},+ "node_modules/@babel/runtime": {+ "version": "7.29.7",+ "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.7.tgz",+ "integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==",+ "license": "MIT",+ "engines": {+ "node": ">=6.9.0"+ }+ },"node_modules/@babel/types": {"version": "7.29.8","resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz",@@ -1230,6 +1240,21 @@"dev": true,"license": "MIT"},+ "node_modules/@lit-labs/ssr-dom-shim": {+ "version": "1.6.0",+ "resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.6.0.tgz",+ "integrity": "sha512-VHb0ALPMTlgKjM6yIxxoQNnpKyUKLD04VzeQdsiXkMqkvYlAHxq9glGLmgbb889/1GsohSOAjvQYoiBppXFqrQ==",+ "license": "BSD-3-Clause"+ },+ "node_modules/@lit/reactive-element": {+ "version": "2.1.2",+ "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-2.1.2.tgz",+ "integrity": "sha512-pbCDiVMnne1lYUIaYNN5wrwQXDtHaYtg7YEFPeW+hws6U47WeFvISGUWekPGKWOP1ygrs0ef0o1VJMk1exos5A==",+ "license": "BSD-3-Clause",+ "dependencies": {+ "@lit-labs/ssr-dom-shim": "^1.5.0"+ }+ },"node_modules/@nodelib/fs.scandir": {"version": "2.1.5","resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",@@ -2266,6 +2291,12 @@"dev": true,"license": "MIT"},+ "node_modules/@types/trusted-types": {+ "version": "2.0.7",+ "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",+ "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",+ "license": "MIT"+ },"node_modules/@types/web-bluetooth": {"version": "0.0.21","resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.21.tgz",@@ -2506,6 +2537,28 @@"url": "https://opencollective.com/eslint"}},+ "node_modules/@uimaxbai/am-lyrics": {+ "version": "1.6.0",+ "resolved": "https://registry.npmjs.org/@uimaxbai/am-lyrics/-/am-lyrics-1.6.0.tgz",+ "integrity": "sha512-5AI8Frakm0v0smxrfNanRzoX5I4AWOdNN2eS0FfdkcW7Oc/YgFbQqes1virHZc76LYX06qKvFQgFrtypQEGm/g==",+ "license": "MPL-2.0",+ "dependencies": {+ "@babel/runtime": "^7.27.6",+ "lit": "^3.1.4"+ },+ "peerDependencies": {+ "@lit/react": "^1.0.0",+ "react": ">=17.0.0"+ },+ "peerDependenciesMeta": {+ "@lit/react": {+ "optional": true+ },+ "react": {+ "optional": true+ }+ }+ },"node_modules/@vitejs/plugin-vue": {"version": "5.2.4","resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-5.2.4.tgz",@@ -5577,6 +5630,37 @@"url": "https://github.com/sponsors/antonk52"}},+ "node_modules/lit": {+ "version": "3.3.3",+ "resolved": "https://registry.npmjs.org/lit/-/lit-3.3.3.tgz",+ "integrity": "sha512-fycuvZg/hkpozL00lm1pEJH5nN/lr9ZXd6mJI2HSN4+Bzc+LDNdEApJ6HFbPkdFNHLvOplIIuJvxkS4XUxqirw==",+ "license": "BSD-3-Clause",+ "dependencies": {+ "@lit/reactive-element": "^2.1.0",+ "lit-element": "^4.2.0",+ "lit-html": "^3.3.0"+ }+ },+ "node_modules/lit-element": {+ "version": "4.2.2",+ "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-4.2.2.tgz",+ "integrity": "sha512-aFKhNToWxoyhkNDmWZwEva2SlQia+jfG0fjIWV//YeTaWrVnOxD89dPKfigCUspXFmjzOEUQpOkejH5Ly6sG0w==",+ "license": "BSD-3-Clause",+ "dependencies": {+ "@lit-labs/ssr-dom-shim": "^1.5.0",+ "@lit/reactive-element": "^2.1.0",+ "lit-html": "^3.3.0"+ }+ },+ "node_modules/lit-html": {+ "version": "3.3.3",+ "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-3.3.3.tgz",+ "integrity": "sha512-el8M6jK2o3RXBnrSHX3ZKrsN8zEV63pSExTO1wYJz7QndGYZ8353e2a5PPX+qHe2aGayfnchQmkAojaWAREOIA==",+ "license": "BSD-3-Clause",+ "dependencies": {+ "@types/trusted-types": "^2.0.2"+ }+ },"node_modules/local-pkg": {"version": "1.1.2","resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-1.1.2.tgz",diff --git a/package.json b/package.jsonindex ca10f400..74553f5a 100755--- a/package.json+++ b/package.json@@ -92,6 +92,7 @@"dependencies": {"@jellyfin/libass-wasm": "4.2.3","@tanstack/vue-query": "^5.77.2",+ "@uimaxbai/am-lyrics": "^1.6.0","@vueuse/components": "^13.0.0","@vueuse/core": "^13.0.0","@vueuse/integrations": "^13.0.0",diff --git a/resources/js/components/video/plugins/lyrics/AmLyrics.vue b/resources/js/components/video/plugins/lyrics/AmLyrics.vuenew file mode 100644index 00000000..d6df3192--- /dev/null+++ b/resources/js/components/video/plugins/lyrics/AmLyrics.vue@@ -0,0 +1,145 @@+<script setup lang="ts">+import { nextTick, onUnmounted, ref, useTemplateRef, watch } from 'vue';+import { FLAGS } from '@/config/featureFlags';++if (FLAGS.USE_AM_LYRICS) {+ await import('@uimaxbai/am-lyrics/am-lyrics.js');+}++const props = defineProps<{+ player: HTMLVideoElement | null;+ title?: string;+ artist?: string;+ album?: string;+ duration: number;+ enabled?: boolean;+}>();++const amLyrics = useTemplateRef<HTMLElement & { currentTime: number }>('am-lyrics');+const hasMounted = ref(false);+const hasStyled = ref(false);++let amLyricsTimeUpdate: (() => void) | null = null;+let amLyricsLineClick: ((e: Event) => void) | null = null;++const initAmLyrics = async () => {+ const el = amLyrics.value;+ const audioPlayer = props.player;+ if (!el || !audioPlayer) return;++ amLyricsTimeUpdate = () => {+ el!.currentTime = audioPlayer.currentTime * 1000;+ };++ amLyricsLineClick = (e: Event) => {+ const { timestamp } = (e as CustomEvent<{ timestamp: number }>).detail;++ audioPlayer.currentTime = timestamp / 1000;+ audioPlayer.play();+ };++ audioPlayer.addEventListener('timeupdate', amLyricsTimeUpdate);+ el.addEventListener('line-click', amLyricsLineClick);++ applyStyle();+};++const destroyAmLyrics = () => {+ if (props.player && amLyricsTimeUpdate) {+ props.player.removeEventListener('timeupdate', amLyricsTimeUpdate);+ }++ if (amLyrics.value && amLyricsLineClick) {+ amLyrics.value.removeEventListener('line-click', amLyricsLineClick);+ }++ amLyricsTimeUpdate = null;+ amLyricsLineClick = null;+};++const applyStyle = () => {+ if (!amLyrics.value?.shadowRoot) return;+ const style = document.createElement('style');+ style.textContent = [+ '.download-controls {margin-right: 110px !important; align-items: start !important; height: 100% !important; margin-top: -4px !important;}',+ '.format-select {min-height: 20px !important;}',+ '.download-button {height: 20px !important;}',+ ].join('');+ amLyrics.value.shadowRoot.appendChild(style);+ hasStyled.value = true;+};++watch(+ () => props.enabled,+ async (enabled) => {+ if (!enabled || hasMounted.value) return;++ hasMounted.value = true;+ await nextTick();+ initAmLyrics();+ },+);++onUnmounted(() => {+ destroyAmLyrics();+});+</script>++<template>+ <am-lyrics+ v-if="FLAGS.USE_AM_LYRICS && hasMounted"+ v-show="enabled"+ ref="am-lyrics"+ class="pointer-events-auto! h-full w-full text-base"+ :song-title="title"+ :song-artist="artist"+ :song-album="album"+ :song-duration="duration * 1000"+ :query="`${artist} ${album} ${title}`"+ :duration="duration * 1000"+ highlight-color="#fff"+ font-family="var(--font-klee-one-mono)"+ autoscroll+ interpolate+ >+ </am-lyrics>+</template>++<style lang="css" scoped>+am-lyrics {+ --lyplus-font-size-base: 24px;+ --am-lyrics-wide-font-size: 26px;+ --am-lyrics-compact-font-size: 20px;++ --am-lyrics-line-spacing: 20px;+ --am-lyrics-wide-line-spacing: 24px;+ --am-lyrics-compact-line-spacing: 16px;++ --am-lyrics-line-height: 1.2;+ --am-lyrics-background-vocal-spacing: 15px;+ --am-lyrics-background-vocal-font-size: 0.65em;+ --am-lyrics-background-vocal-stack-shift: 7.5px;+ --am-lyrics-background-vocal-max-height: 2em;+ --am-lyrics-background-vocal-exit-duration: 450ms;+ --am-lyrics-instrumental-height: 40px;+ --am-lyrics-instrumental-spacing: 16px;+ --am-lyrics-instrumental-enter-duration: 400ms;+ --am-lyrics-instrumental-collapse-duration: 500ms;+ --am-lyrics-instrumental-exit-duration: 350ms;+ --am-lyrics-instrumental-exit-scale: 0;+ --am-lyrics-inactive-scale: 0.98;+ --am-lyrics-background-vocal-scale: 0.9;+ --am-lyrics-touch-scale: 0.96;+ --am-lyrics-highlight-radius: 16px;+ --am-lyrics-highlight-surface: rgba(255, 255, 255, 0.08);+ --am-lyrics-progression-feather: 30px;+ --am-lyrics-glow-radius: 5px;+ --am-lyrics-character-rise-peak: -1.25px;+ --am-lyrics-inline-padding: 20px;+ --lyrics-scroll-padding-top: 12%;+ --am-lyrics-compact-background-vocal-font-size: 0.857em;+ --am-lyrics-compact-selected-position: 18%;+ --am-lyrics-wide-background-vocal-font-size: 0.667em;+ --am-lyrics-wide-selected-position: 20%;+}+</style>diff --git a/resources/js/components/video/plugins/lyrics/VideoLyrics.vue b/resources/js/components/video/plugins/lyrics/VideoLyrics.vueindex 2e66af6c..9a658b52 100644--- a/resources/js/components/video/plugins/lyrics/VideoLyrics.vue+++ b/resources/js/components/video/plugins/lyrics/VideoLyrics.vue@@ -7,9 +7,11 @@ import { useModalStore } from '@/stores/ModalStore';import { useLyricStore } from '@/stores/LyricStore';import { storeToRefs } from 'pinia';import { onSeek } from '@/service/player/seekBus';+import { FLAGS } from '@/config/featureFlags';import PlayerToolbarButton from '@/components/video/button/PlayerToolbarButton.vue';import VideoLyricItem from '@/components/video/plugins/lyrics/VideoLyricItem.vue';+import AmLyrics from '@/components/video/plugins/lyrics/AmLyrics.vue';let unsubscribe: () => boolean;@@ -31,6 +33,7 @@ const isContainerVisible = ref(false);const isFocusedScroll = ref(false);const useFocusedScroll = ref(true);+const useAmLyrics = ref(false);const lyrics = computed(() => {const availableLyrics = stateLyrics.value;@@ -257,10 +260,14 @@ watch(defineExpose({ scrollToCurrent });</script><template>+ <Suspense v-if="FLAGS.USE_AM_LYRICS">+ <AmLyrics :enabled="useAmLyrics" :player="player" :title="stateVideo.title" :artist="stateVideo.artist" :album="stateVideo.album" :duration="timeDuration" />+ <template #fallback> ... </template>+ </Suspense><section- class="fade-mask scrollbar-hide flex h-full w-full flex-col overflow-y-scroll text-center text-sm sm:text-xl"+ class="fade-mask font-klee-one-mono scrollbar-hide flex h-full w-full flex-col overflow-y-scroll text-center text-sm sm:text-xl"ref="lyrics-container"- v-show="lyrics.length > 0"+ v-show="lyrics.length > 0 && !useAmLyrics"@wheel="handleUserScroll"@touchmove="handleUserScroll">@@ -287,11 +294,16 @@ defineExpose({ scrollToCurrent });/><div class="shrink-0" style="height: 45%"></div></section>- <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 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 @click="toggleFocusScroll" title="Focus active lyric"> {{ useFocusedScroll ? 'disable' : 'enable' }} focus </PlayerToolbarButton>- <PlayerToolbarButton @click="handleOpenLyricsModal" title="Edit lyrics" :is-active="!!dirtyLyric">+ <PlayerToolbarButton v-if="FLAGS.USE_AM_LYRICS" @click="useAmLyrics = FLAGS.USE_AM_LYRICS ? !useAmLyrics : false" title="Use alternate lyrics viewer">+ {{ useAmLyrics ? 'use native lyrics' : 'use am-Lyrics' }}+ </PlayerToolbarButton>+ <PlayerToolbarButton v-if="!useAmLyrics" @click="toggleFocusScroll" title="Focus active lyric"> {{ useFocusedScroll ? 'disable' : 'enable' }} focus </PlayerToolbarButton>+ <PlayerToolbarButton v-if="!useAmLyrics" @click="handleOpenLyricsModal" title="Edit lyrics" :is-active="!!dirtyLyric">{{ dirtyLyric ? 'preview' : 'edit' }}</PlayerToolbarButton></Teleport>diff --git a/resources/js/config/featureFlags.ts b/resources/js/config/featureFlags.tsindex 9a8eedd5..f250d0a5 100644--- a/resources/js/config/featureFlags.ts+++ b/resources/js/config/featureFlags.ts@@ -12,6 +12,8 @@ export const FLAGS = {USE_TRANSPARENT_HOME_CARDS: true,+ USE_AM_LYRICS: true,+CONFIG: {USE_MEDIA_EXTENSION_CONFIG: true, // Allow setting supported extensionsUSE_SUBTITLE_EXTENSION_CONFIG: false, // Allow setting supported subtitle extensionsdiff --git a/vite.config.ts b/vite.config.tsindex e522c971..f4a19c1f 100644--- a/vite.config.ts+++ b/vite.config.ts@@ -31,6 +31,9 @@ export default defineConfig({base: null,includeAbsolute: false,},+ compilerOptions: {+ isCustomElement: (tag) => tag === 'am-lyrics',+ },},}),viteStaticCopy({