From 801c04c07e44ee1fa6868ce0778984e44c7f46f0 Mon Sep 17 00:00:00 2001 From: wvffle Date: Mon, 25 Jul 2022 01:00:50 +0000 Subject: [PATCH] Fix radios starting from second track --- front/src/composables/audio/useSound.ts | 7 ++++++- front/src/store/queue.ts | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/front/src/composables/audio/useSound.ts b/front/src/composables/audio/useSound.ts index d9f824f0c..7648b733a 100644 --- a/front/src/composables/audio/useSound.ts +++ b/front/src/composables/audio/useSound.ts @@ -46,7 +46,12 @@ const createSound = (howl: Howl): Sound => ({ seek: (time?: number) => howl.seek(time), duration: () => howl.duration(), getSource: () => (howl as any)._sounds[0], - triggerSoundProgress: useThrottleFn((time: number, duration: number) => soundProgress.trigger({ node: (howl as any)._sounds[0]._node, time, duration }), 1000) + triggerSoundProgress: useThrottleFn((time: number, duration: number) => { + const node = (howl as any)._sounds[0]?._node + if (node) { + soundProgress.trigger({ node, time, duration }) + } + }, 1000) }) const loadSound = (track: Track): Sound => { diff --git a/front/src/store/queue.ts b/front/src/store/queue.ts index eec5b0787..06e1c83ff 100644 --- a/front/src/store/queue.ts +++ b/front/src/store/queue.ts @@ -87,6 +87,7 @@ const store: Module = { const shouldPlay = state.tracks.length === 0 if (shouldPlay) { index = 0 + state.currentIndex = 0 } if (index >= state.tracks.length) {