From 657c8051f8e90883573ccea20a44c269f3bbeb4e Mon Sep 17 00:00:00 2001 From: minjaesong Date: Mon, 8 Jul 2024 17:30:39 +0900 Subject: [PATCH] working prev/next music queueing --- src/net/torvald/terrarum/MusicService.kt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/net/torvald/terrarum/MusicService.kt b/src/net/torvald/terrarum/MusicService.kt index 48381ea0f..db96dcf80 100644 --- a/src/net/torvald/terrarum/MusicService.kt +++ b/src/net/torvald/terrarum/MusicService.kt @@ -248,8 +248,7 @@ object MusicService : TransactionListener() { // request fadeout App.audioMixer.requestFadeOut(App.audioMixer.musicTrack) { try { - // callback: play next song in the playlist - // TODO queue the next song on the playlist, the actual playback will be done by the state machine update + // do nothing, really fadedOut = true } @@ -263,6 +262,8 @@ object MusicService : TransactionListener() { } override fun onSuccess(state: TransactionState) { + enterSTATE_INTERMISSION(0f) + enterSTATE_FIREPLAY() onSuccess() } override fun onFailure(e: Throwable, state: TransactionState) { @@ -279,8 +280,10 @@ object MusicService : TransactionListener() { // request fadeout App.audioMixer.requestFadeOut(App.audioMixer.musicTrack) { try { - // callback: play prev song in the playlist - // TODO queue the prev song on the playlist, the actual playback will be done by the state machine update + // unshift the playlist + // FIREPLAY always pulls next track, that's why we need two prev() + (state["currentPlaylist"] as TerrarumMusicPlaylist).queuePrev() + (state["currentPlaylist"] as TerrarumMusicPlaylist).queuePrev() fadedOut = true } @@ -294,9 +297,15 @@ object MusicService : TransactionListener() { } override fun onSuccess(state: TransactionState) { + + enterSTATE_INTERMISSION(0f) + enterSTATE_FIREPLAY() onSuccess() } override fun onFailure(e: Throwable, state: TransactionState) { + // reshift the playlist + (state["currentPlaylist"] as TerrarumMusicPlaylist).queueNext() + e.printStackTrace() } }