fix: allowing prev and next on iOS

This commit is contained in:
Phan An 2024-06-07 15:08:50 +02:00
parent 31a8284c88
commit 271bb7a5d1
7 changed files with 16 additions and 16 deletions

View file

@ -111,7 +111,7 @@ const playOrPause = async () => {
queueStore.replaceQueueWith(orderBy(await episodeStore.fetchForPodcast(podcast.value.id), 'created_at')) queueStore.replaceQueueWith(orderBy(await episodeStore.fetchForPodcast(podcast.value.id), 'created_at'))
} }
playbackService.play(episode.value, currentPosition.value >= episode.value.length ? 0 : currentPosition.value) await playbackService.play(episode.value, currentPosition.value >= episode.value.length ? 0 : currentPosition.value)
} }
</script> </script>

View file

@ -179,14 +179,14 @@ const playButtonLabel = computed(() => {
return inProgress.value ? 'Continue' : 'Start Listening' return inProgress.value ? 'Continue' : 'Start Listening'
}) })
const playOrPause = () => { const playOrPause = async () => {
if (podcastPlaying.value) { if (podcastPlaying.value) {
playbackService.pause() playbackService.pause()
return return
} }
if (currentPlayingItemIsPartOfPodcast.value) { if (currentPlayingItemIsPartOfPodcast.value) {
playbackService.resume() await playbackService.resume()
return return
} }
@ -194,13 +194,13 @@ const playOrPause = () => {
const currentEpisode = episodes.value?.find(episode => episode.id === podcast.value?.state.current_episode) const currentEpisode = episodes.value?.find(episode => episode.id === podcast.value?.state.current_episode)
if (!currentEpisode) return if (!currentEpisode) return
playbackService.play(currentEpisode, podcast.value?.state.progresses[currentEpisode.id] || 0) await playbackService.play(currentEpisode, podcast.value?.state.progresses[currentEpisode.id] || 0)
return return
} }
if (!episodes.value?.length) return if (!episodes.value?.length) return
queueStore.replaceQueueWith(orderBy(episodes.value, 'created_at')) queueStore.replaceQueueWith(orderBy(episodes.value, 'created_at'))
playbackService.playFirstInQueue() await playbackService.playFirstInQueue()
} }
const refresh = async () => { const refresh = async () => {

View file

@ -111,14 +111,14 @@ const clearQueue = () => {
queueStore.clear() queueStore.clear()
} }
const removeSelected = () => { const removeSelected = async () => {
if (!selectedPlayables.value.length) return if (!selectedPlayables.value.length) return
const currentSongId = queueStore.current?.id const currentSongId = queueStore.current?.id
queueStore.unqueue(selectedPlayables.value) queueStore.unqueue(selectedPlayables.value)
if (currentSongId && selectedPlayables.value.find(({ id }) => id === currentSongId)) { if (currentSongId && selectedPlayables.value.find(({ id }) => id === currentSongId)) {
playbackService.playNext() await playbackService.playNext()
} }
} }

View file

@ -183,7 +183,7 @@ const canBeRemovedFromPlaylist = computed(() => {
const isQueueScreen = computed(() => isCurrentScreen('Queue')) const isQueueScreen = computed(() => isCurrentScreen('Queue'))
const isFavoritesScreen = computed(() => isCurrentScreen('Favorites')) const isFavoritesScreen = computed(() => isCurrentScreen('Favorites'))
const doPlayback = () => trigger(() => { const doPlayback = () => trigger(async () => {
if (!playables.value.length) return if (!playables.value.length) return
switch (playables.value[0].playback_state) { switch (playables.value[0].playback_state) {
@ -192,11 +192,11 @@ const doPlayback = () => trigger(() => {
break break
case 'Paused': case 'Paused':
playbackService.resume() await playbackService.resume()
break break
default: default:
playbackService.play(playables.value[0]) await playbackService.play(playables.value[0])
break break
} }
}) })

View file

@ -389,12 +389,12 @@ const openContextMenu = async (row: PlayableRow, event: MouseEvent) => {
eventBus.emit('PLAYABLE_CONTEXT_MENU_REQUESTED', event, selectedPlayables.value) eventBus.emit('PLAYABLE_CONTEXT_MENU_REQUESTED', event, selectedPlayables.value)
} }
const onPlay = (playable: Playable) => { const onPlay = async (playable: Playable) => {
if (shouldTriggerContinuousPlayback.value) { if (shouldTriggerContinuousPlayback.value) {
queueStore.replaceQueueWith(getAllPlayablesWithSort()) queueStore.replaceQueueWith(getAllPlayablesWithSort())
} }
playbackService.play(playable) await playbackService.play(playable)
} }
defineExpose({ defineExpose({

View file

@ -48,12 +48,12 @@ const title = computed(() => {
return 'Play' return 'Play'
}) })
const playOrPause = () => { const playOrPause = async () => {
if (playable.value.playback_state === 'Stopped') { if (playable.value.playback_state === 'Stopped') {
// @todo play at the right playback position for Episodes // @todo play at the right playback position for Episodes
play() await play()
} else if (playable.value.playback_state === 'Paused') { } else if (playable.value.playback_state === 'Paused') {
playbackService.resume() await playbackService.resume()
} else { } else {
playbackService.pause() playbackService.pause()
} }

View file

@ -54,7 +54,7 @@ const initiatePlayback = async () => {
break break
} }
playbackService.queueAndPlay(playables) await playbackService.queueAndPlay(playables)
go('queue') go('queue')
} }
</script> </script>