A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
feat: subtitle loading indicators
aminnausinf28e1b30662b
diff --git a/package-lock.json b/package-lock.jsonindex abca9167..05c8c370 100755--- a/package-lock.json+++ b/package-lock.json@@ -24,7 +24,7 @@"vue-router": "^4.5.0"},"devDependencies": {- "@aminnausin/cedar-ui": "^0.0.15",+ "@aminnausin/cedar-ui": "^0.0.16","@eslint/js": "^9.7.0","@faker-js/faker": "^9.8.0","@iconify-json/circum": "^1.2.2",@@ -75,9 +75,9 @@}},"node_modules/@aminnausin/cedar-ui": {- "version": "0.0.15",- "resolved": "https://registry.npmjs.org/@aminnausin/cedar-ui/-/cedar-ui-0.0.15.tgz",- "integrity": "sha512-LReAjdUmYGzINIATuJEDK2kmL27AVT8yKhSlMfGuTQRiEZQp54afmkdUnVekUCeHmNO7Vo5pIvfTTZkf3WEVzA==",+ "version": "0.0.16",+ "resolved": "https://registry.npmjs.org/@aminnausin/cedar-ui/-/cedar-ui-0.0.16.tgz",+ "integrity": "sha512-CC/xwlrx3PmPaloOOWb42A+m187HMgSD6I6S65iRZFLHzF0828uLBM738AkENg+O/1RinQRkj2GzIuybWVBV8g==","dev": true,"license": "MIT","dependencies": {diff --git a/package.json b/package.jsonindex 6bcd0047..49ba8422 100755--- a/package.json+++ b/package.json@@ -41,7 +41,7 @@"docker:build-linux-latest": "docker build . -t aminnausin/mediaserver:latest --build-arg GIT_COMMIT=$(git rev-parse --short HEAD) --build-arg GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo unknown) && docker push aminnausin/mediaserver:latest"},"devDependencies": {- "@aminnausin/cedar-ui": "^0.0.15",+ "@aminnausin/cedar-ui": "^0.0.16","@eslint/js": "^9.7.0","@faker-js/faker": "^9.8.0","@iconify-json/circum": "^1.2.2",diff --git a/resources/js/components/cedar-ui/toast/ToastNotification.vue b/resources/js/components/cedar-ui/toast/ToastNotification.vueindex fff60474..5541d569 100644--- a/resources/js/components/cedar-ui/toast/ToastNotification.vue+++ b/resources/js/components/cedar-ui/toast/ToastNotification.vue@@ -2,7 +2,7 @@import type { SwipeDirection, ToastProps } from '@aminnausin/cedar-ui';import { useToastTimer, useSwipeHandler, SWIPE_THRESHOLD, TOAST_LIFE, VISIBLE_TOASTS_AMOUNT, cn } from '@aminnausin/cedar-ui';-import { CedarDanger, CedarInfo, CedarSuccess, CedarWarning } from '../icons';+import { CedarDanger, CedarInfo, CedarSuccess, CedarWarning, SvgSpinners90RingWithBg } from '../icons';import { computed, onBeforeUnmount, onMounted, ref } from 'vue';import { ButtonCorner } from '../button';@@ -58,8 +58,8 @@ const { offset, isSwiping, onPointerDown, onPointerMove, onPointerUp } = useSwip});const { cancel: cancelToastTimer } = useToastTimer({- duration: props.life || TOAST_LIFE,- isPaused: () => props.expanded || props.type === 'loading' || !props.life || props.life === Infinity || toastHovered.value,+ duration: () => props.life || TOAST_LIFE,+ isPaused: () => props.expanded || !props.life || props.life === Infinity || toastHovered.value,onTimeout: onClose,});@@ -166,7 +166,7 @@ onBeforeUnmount(() => {'text-info': type === 'info','text-warning': type === 'warning','text-danger-1': type === 'danger',- 'text-foreground-0': type === 'default',+ 'text-foreground-0': type === 'default' || type === 'promise',},]">@@ -174,6 +174,7 @@ onBeforeUnmount(() => {<CedarInfo v-if="type === 'info'" class="toast-icon" /><CedarWarning v-if="type === 'warning'" class="toast-icon" /><CedarDanger v-if="type === 'danger'" class="toast-icon" />+ <SvgSpinners90RingWithBg v-if="type === 'promise'" class="toast-icon" /></div><div class="space-y-1.5"><h6@@ -184,7 +185,7 @@ onBeforeUnmount(() => {'text-info': type === 'info','text-warning': type === 'warning','text-danger-1': type === 'danger',- 'text-foreground-0': type === 'default',+ 'text-foreground-0': type === 'default' || type === 'promise',},]":title="title"diff --git a/resources/js/components/video/subtitles/OctopusRenderer.ts b/resources/js/components/video/subtitles/OctopusRenderer.tsindex ba0f7375..c32fb0df 100644--- a/resources/js/components/video/subtitles/OctopusRenderer.ts+++ b/resources/js/components/video/subtitles/OctopusRenderer.ts@@ -1,19 +1,26 @@import type { SubtitlesOctopusOptions } from '@jellyfin/libass-wasm';import type SubtitlesOctopus from '@jellyfin/libass-wasm';+import { toast } from '@aminnausin/cedar-ui';import { ref } from 'vue';export default function useOctopusRenderer() {const assInstance = ref<SubtitlesOctopus | null>(null);const instantiateOctopus = async (subUrl: string, language?: string, frameRate?: number) => {- clearOctopus();const video = document.getElementById('video-source') as HTMLVideoElement;if (!video) return;+ if (assInstance.value) clearOctopus();const baseFonts = ['/fonts/Rubik-Regular.ttf']; // Latin, Arabic, Cyrillicconst supplementalFonts = generateLanguageFonts(language);+ await toast.promise(fetch(subUrl), {+ loading: 'Loading subtitle track...',+ success: 'Track loaded',+ error: 'Failed to load subtitle track',+ });+import('@jellyfin/libass-wasm').then(({ default: SubtitlesOctopus }) => {const options: SubtitlesOctopusOptions = {video,@@ -21,22 +28,19 @@ export default function useOctopusRenderer() {fonts: [...baseFonts, ...supplementalFonts],workerUrl: '/build/lib/subtitles-octopus/subtitles-octopus-worker.js',fallbackFont: '/fonts/NotoSans-Regular.ttf',- onError(e?: any) {- console.log('Subtitles failed', e);+ onError() {+ toast.error('Subtitles Failed');clearOctopus();},targetFps: frameRate || 24,- renderAhead: 60,};assInstance.value = new SubtitlesOctopus(options);});};const clearOctopus = () => {- if (assInstance.value?.worker) {- // Supposedly the jellyfin version disposes itself on error?- assInstance.value.dispose();- }+ // Supposedly the jellyfin version disposes itself on error?+ assInstance.value?.dispose();assInstance.value = null;};