Fix mini-player showing last track during inter-track silence, (#10401)

and music not looping when having only Thatched Villagers available.
This commit is contained in:
SomeTroglodyte 2023-11-02 23:09:23 +01:00 committed by GitHub
parent 9970549543
commit c9d10cd8e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -121,19 +121,19 @@ class MusicController {
private var musicTimer: Timer? = null
private enum class ControllerState(val canPause: Boolean = false) {
private enum class ControllerState(val canPause: Boolean = false, val showTrack: Boolean = false) {
/** Own timer stopped, if using the HardenedGdxAudio callback just do nothing */
Idle,
/** Loop will release everything and go [Idle] if it encounters this state. */
Cleanup,
/** Play a track to its end, then silence for a while, then choose another track */
Playing(true),
Playing(true, true),
/** Play a track to its end, then [Cleanup] */
PlaySingle(true),
PlaySingle(true, true),
/** Wait for a while in silence to start next track */
Silence(true),
/** Music fades to pause or is paused. Continue with chooseTrack or resume. */
Pause,
Pause(showTrack = true),
/** Fade out then [Cleanup] */
Shutdown
}
@ -168,7 +168,7 @@ class MusicController {
/** @return the path of the playing track or empty string if none playing */
private fun currentlyPlaying(): String =
if (state.canPause) musicHistory.lastOrNull() ?: ""
if (state.showTrack) musicHistory.lastOrNull() ?: ""
else ""
/** Registers a callback that will be called with the new track every time it changes.