A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
chore: player refactoring
aminnausin0c94a1ecbf48
diff --git a/resources/js/components/video/VideoInfoPanel.vue b/resources/js/components/video/VideoInfoPanel.vueindex 9a96e79b..0d52994b 100755--- a/resources/js/components/video/VideoInfoPanel.vue+++ b/resources/js/components/video/VideoInfoPanel.vue@@ -8,7 +8,7 @@ import { getUserViewCount } from '@/service/mediaAPI';import { useContentStore } from '@/stores/ContentStore';import { useAuthStore } from '@/stores/AuthStore';import { storeToRefs } from 'pinia';-import { emitSeek } from '@/service/video/seekBus';+import { emitSeek } from '@/service/player/seekBus';import { useRoute } from 'vue-router';import ButtonClipboard from '@/components/pinesUI/ButtonClipboard.vue';diff --git a/resources/js/components/video/VideoLyrics.vue b/resources/js/components/video/VideoLyrics.vueindex 513827a8..a5fe0efe 100644--- a/resources/js/components/video/VideoLyrics.vue+++ b/resources/js/components/video/VideoLyrics.vue@@ -8,7 +8,7 @@ import { toFormattedDuration } from '@/service/util';import { useContentStore } from '@/stores/ContentStore';import { useLyricStore } from '@/stores/LyricStore';import { storeToRefs } from 'pinia';-import { onSeek } from '@/service/video/seekBus';+import { onSeek } from '@/service/player/seekBus';import VideoLyricItem from '@/components/video/VideoLyricItem.vue';import EditLyrics from '@/components/forms/EditLyrics.vue';@@ -210,7 +210,7 @@ watch(() => props.isPaused, handleUpdate);watch(() => stateVideo.value, resetComponent);</script><template>- <section class="flex flex-col h-full w-full overflow-y-scroll scrollbar-hide text-sm sm:text-xl text-center fade-mask" ref="lyrics-container" v-show="lyrics.length > 0">+ <section class="fade-mask flex h-full w-full flex-col overflow-y-scroll text-center text-sm scrollbar-hide sm:text-xl" ref="lyrics-container" v-show="lyrics.length > 0"><div class="shrink-0" style="height: 45%"></div><VideoLyricItemv-for="(lyric, index) in lyrics"@@ -232,12 +232,12 @@ watch(() => stateVideo.value, resetComponent);/><div class="shrink-0" style="height: 45%"></div></section>- <div class="absolute top-0 left-0 right-0 h-12 pointer-events-auto" style="z-index: 6"></div>- <div class="absolute bottom-0 left-0 right-0 h-16 pointer-events-auto" style="z-index: 6"></div>- <div class="absolute top-4 right-4 flex gap-1" style="z-index: 7" v-show="!isFullscreen">+ <div class="pointer-events-auto absolute left-0 right-0 top-0 h-12" style="z-index: 6"></div>+ <div class="pointer-events-auto absolute bottom-0 left-0 right-0 h-16" style="z-index: 6"></div>+ <div class="absolute right-4 top-4 flex gap-1" style="z-index: 7" v-show="!isFullscreen"><ButtonIconvariant="ghost"- :class="`${dirtyLyric ? 'rounded-full opacity-90' : 'opacity-70 rounded-md bg-transparent'} px-2 pointer-events-auto hover:opacity-100 hover:text-yellow-500 hover:bg-neutral-900/30 bg-neutral-900/10 transition p-1`"+ :class="`${dirtyLyric ? 'rounded-full opacity-90' : 'rounded-md bg-transparent opacity-70'} pointer-events-auto bg-neutral-900/10 p-1 px-2 transition hover:bg-neutral-900/30 hover:text-yellow-500 hover:opacity-100`"@click="handleOpenLyricsModal"title="Edit Lyrics">diff --git a/resources/js/components/video/VideoPlayer.vue b/resources/js/components/video/VideoPlayer.vueindex 23627808..08e5f443 100755--- a/resources/js/components/video/VideoPlayer.vue+++ b/resources/js/components/video/VideoPlayer.vue@@ -3,9 +3,10 @@ import type { FolderResource, VideoResource } from '@/types/resources';import type { ContextMenuItem, PopoverItem } from '@/types/types';import type { ComputedRef, Ref } from 'vue';+import { controlsHideTime, playbackDataBuffer, playerHealthBuffer, volumeDelta, playbackDelta, playbackMin, playbackMax } from '@/service/player/playerConstants';import { getScreenSize, handleStorageURL, isInputLikeElement, isMobileDevice, toFormattedDate, toFormattedDuration } from '@/service/util';import { computed, nextTick, onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue';-import { copyVideoFrame, saveVideoFrame } from '@/service/video/frameService';+import { copyVideoFrame, saveVideoFrame } from '@/service/player/frameService';import { useRoute, useRouter } from 'vue-router';import { UseCreatePlayback } from '@/service/mutations';import { useVideoPlayback } from '@/service/queries';@@ -16,7 +17,7 @@ import { useAppStore } from '@/stores/AppStore';import { storeToRefs } from 'pinia';import { getMediaUrl } from '@/service/api';import { MediaType } from '@/types/types';-import { onSeek } from '@/service/video/seekBus';+import { onSeek } from '@/service/player/seekBus';import { toast } from '@/service/toaster/toastService';import VideoPopoverSlider from '@/components/video/VideoPopoverSlider.vue';@@ -89,13 +90,6 @@ import CircumTimer from '~icons/circum/timer';* 30 → Context Menu (Global overlay in fullscreen)*/-const controlsHideTime: number = 2500; // Time before controls auto hide-const playbackDataBuffer: number = 5; // Number of seeks needed to upload-const playerHealthBuffer: number = 12; // Number of player yime updates needed to fetch info-const volumeDelta: number = 0.05; // Volume change rate-const playbackDelta: number = 0.05; // Speed change rate-const playbackMin: number = 0.1; // Min speed-const playbackMax: number = 3; // Max speedconst router = useRouter();const route = useRoute();@@ -978,11 +972,7 @@ watch(isPictureInPicture, async (value) => {if (!player.value || isLoading.value) return;try {- if (value) {- await player.value.requestPictureInPicture().catch((error: Error) => {- throw error;- });- } else if (document.pictureInPictureElement) document.exitPictureInPicture();+ await (value ? player.value.requestPictureInPicture() : document.exitPictureInPicture());popover.value?.handleClose();} catch (error) {diff --git a/resources/js/service/video/frameService.test.ts b/resources/js/service/player/frameService.test.tssimilarity index 100%rename from resources/js/service/video/frameService.test.tsrename to resources/js/service/player/frameService.test.tsdiff --git a/resources/js/service/video/frameService.ts b/resources/js/service/player/frameService.tssimilarity index 100%rename from resources/js/service/video/frameService.tsrename to resources/js/service/player/frameService.tsdiff --git a/resources/js/service/player/playerConstants.ts b/resources/js/service/player/playerConstants.tsnew file mode 100644index 00000000..6d7468ef--- /dev/null+++ b/resources/js/service/player/playerConstants.ts@@ -0,0 +1,9 @@+const controlsHideTime: number = 2500; // Time before controls auto hide+const playbackDataBuffer: number = 5; // Number of seeks needed to upload+const playerHealthBuffer: number = 12; // Number of player yime updates needed to fetch info+const volumeDelta: number = 0.05; // Volume change rate+const playbackDelta: number = 0.05; // Speed change rate+const playbackMin: number = 0.1; // Min speed+const playbackMax: number = 3; // Max speed++export { controlsHideTime, playbackDataBuffer, playerHealthBuffer, volumeDelta, playbackDelta, playbackMin, playbackMax };diff --git a/resources/js/service/video/seekBus.ts b/resources/js/service/player/seekBus.tssimilarity index 100%rename from resources/js/service/video/seekBus.tsrename to resources/js/service/player/seekBus.ts