Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2346>
environments/review-docs-nginx-aqlin2/deployments/17397
Kasper Seweryn 2023-01-29 00:04:09 +01:00 zatwierdzone przez Marge
rodzic d3b3463415
commit b21edbb64d
2 zmienionych plików z 24 dodań i 10 usunięć

Wyświetl plik

@ -192,7 +192,14 @@ export const usePlayer = createGlobalState(() => {
return sound.isErrored.value
})
const { start: startErrorTimeout, stop: stopErrorTimeout } = useTimeoutFn(() => playNext(), 3000, { immediate: false })
const { start: startErrorTimeout, stop: stopErrorTimeout } = useTimeoutFn(() => {
if (looping.value !== LoopingMode.LoopTrack) {
return playNext()
}
isPlaying.value = false
}, 3000, { immediate: false })
watch(currentIndex, stopErrorTimeout)
whenever(errored, startErrorTimeout)

Wyświetl plik

@ -109,6 +109,18 @@ export const useTracks = createGlobalState(() => {
return soundPromise
}
// Skip when errored
const { start: soundUnplayable, stop: abortSoundUnplayableTimeout } = useTimeoutFn(() => {
const { isPlaying, looping, LoopingMode } = usePlayer()
const { playNext } = useQueue()
if (looping.value !== LoopingMode.LoopTrack) {
return playNext()
}
isPlaying.value = false
}, 3000, { immediate: false })
// Preload next track
const { start: startPreloadTimeout } = useTimeoutFn(async (index) => {
const { queue } = useQueue()
@ -118,7 +130,9 @@ export const useTracks = createGlobalState(() => {
// Create track from queue
const createTrack = async (index: number) => {
const { queue, currentIndex, playNext, hasNext } = useQueue()
abortSoundUnplayableTimeout()
const { queue, currentIndex } = useQueue()
if (queue.value.length <= index || index === -1) return
console.log('LOADING TRACK', index)
@ -126,14 +140,7 @@ export const useTracks = createGlobalState(() => {
const sound = await createSound(track)
if (!sound.playable) {
setTimeout(() => {
if (hasNext.value && index !== queue.value.length - 1) {
return playNext(true)
}
const { isPlaying } = usePlayer()
isPlaying.value = false
}, 3000)
soundUnplayable()
return
}