mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-22 12:38:29 +07:00
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:
parent
9970549543
commit
c9d10cd8e1
@ -121,19 +121,19 @@ class MusicController {
|
|||||||
|
|
||||||
private var musicTimer: Timer? = null
|
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 */
|
/** Own timer stopped, if using the HardenedGdxAudio callback just do nothing */
|
||||||
Idle,
|
Idle,
|
||||||
/** Loop will release everything and go [Idle] if it encounters this state. */
|
/** Loop will release everything and go [Idle] if it encounters this state. */
|
||||||
Cleanup,
|
Cleanup,
|
||||||
/** Play a track to its end, then silence for a while, then choose another track */
|
/** 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] */
|
/** Play a track to its end, then [Cleanup] */
|
||||||
PlaySingle(true),
|
PlaySingle(true, true),
|
||||||
/** Wait for a while in silence to start next track */
|
/** Wait for a while in silence to start next track */
|
||||||
Silence(true),
|
Silence(true),
|
||||||
/** Music fades to pause or is paused. Continue with chooseTrack or resume. */
|
/** Music fades to pause or is paused. Continue with chooseTrack or resume. */
|
||||||
Pause,
|
Pause(showTrack = true),
|
||||||
/** Fade out then [Cleanup] */
|
/** Fade out then [Cleanup] */
|
||||||
Shutdown
|
Shutdown
|
||||||
}
|
}
|
||||||
@ -168,7 +168,7 @@ class MusicController {
|
|||||||
|
|
||||||
/** @return the path of the playing track or empty string if none playing */
|
/** @return the path of the playing track or empty string if none playing */
|
||||||
private fun currentlyPlaying(): String =
|
private fun currentlyPlaying(): String =
|
||||||
if (state.canPause) musicHistory.lastOrNull() ?: ""
|
if (state.showTrack) musicHistory.lastOrNull() ?: ""
|
||||||
else ""
|
else ""
|
||||||
|
|
||||||
/** Registers a callback that will be called with the new track every time it changes.
|
/** Registers a callback that will be called with the new track every time it changes.
|
||||||
|
Loading…
Reference in New Issue
Block a user