fix(playback): await all async methods in interna API
Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2306>
This commit is contained in:
parent
b04e087ca6
commit
af6b5c3843
|
@ -96,11 +96,11 @@ export class HTMLSound implements Sound {
|
|||
}
|
||||
|
||||
async play () {
|
||||
this.#audio.play()
|
||||
return this.#audio.play()
|
||||
}
|
||||
|
||||
async pause () {
|
||||
this.#audio.pause()
|
||||
return this.#audio.pause()
|
||||
}
|
||||
|
||||
async seekTo (seconds: number) {
|
||||
|
|
|
@ -36,11 +36,10 @@ export const usePlayer = createGlobalState(() => {
|
|||
if (!sound) return
|
||||
|
||||
if (isPlaying.value) {
|
||||
sound.play()
|
||||
return
|
||||
return sound.play()
|
||||
}
|
||||
|
||||
sound.pause()
|
||||
return sound.pause()
|
||||
})
|
||||
|
||||
// Create first track when we initialize the page
|
||||
|
|
|
@ -183,15 +183,15 @@ export const useQueue = createGlobalState(() => {
|
|||
|
||||
// Play track
|
||||
const playTrack = async (trackIndex: number, forceRestartIfCurrent = false) => {
|
||||
if (isPlaying.value) currentSound.value?.pause()
|
||||
if (currentIndex.value !== trackIndex) currentSound.value?.seekTo(0)
|
||||
if (isPlaying.value) await currentSound.value?.pause()
|
||||
if (currentIndex.value !== trackIndex) await currentSound.value?.seekTo(0)
|
||||
|
||||
const shouldRestart = forceRestartIfCurrent && currentIndex.value === trackIndex
|
||||
const nextTrackIsTheSame = queue.value[trackIndex]?.id === currentTrack.value?.id
|
||||
|
||||
if (shouldRestart || nextTrackIsTheSame) {
|
||||
currentSound.value?.seekTo(0)
|
||||
if (isPlaying.value) currentSound.value?.play()
|
||||
await currentSound.value?.seekTo(0)
|
||||
if (isPlaying.value) await currentSound.value?.play()
|
||||
if (shouldRestart) return
|
||||
}
|
||||
|
||||
|
@ -303,8 +303,8 @@ export const useQueue = createGlobalState(() => {
|
|||
// Clear
|
||||
const clearRadio = ref(false)
|
||||
const clear = async () => {
|
||||
currentSound.value?.pause()
|
||||
currentSound.value?.seekTo(0)
|
||||
await currentSound.value?.pause()
|
||||
await currentSound.value?.seekTo(0)
|
||||
currentSound.value?.dispose()
|
||||
|
||||
clearRadio.value = true
|
||||
|
|
Loading…
Reference in New Issue