Fixed music player issues with handling repeat tracks.

When pressing the "next" button, songs will only be pushed when a new track plays.  Fixes a potential null pointer crash.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2014-12-24 00:25:26 -05:00
parent 33f5df030c
commit 068a844e1f
2 changed files with 8 additions and 5 deletions

View File

@ -251,7 +251,7 @@ public class Game extends BasicGameState {
if (checkpointLoaded) { if (checkpointLoaded) {
int checkpoint = Options.getCheckpoint(); int checkpoint = Options.getCheckpoint();
String checkpointText = String.format( String checkpointText = String.format(
"~ Playing from checkpoint at %02d:%02d. ~", "Playing from checkpoint at %02d:%02d.",
TimeUnit.MILLISECONDS.toMinutes(checkpoint), TimeUnit.MILLISECONDS.toMinutes(checkpoint),
TimeUnit.MILLISECONDS.toSeconds(checkpoint) - TimeUnit.MILLISECONDS.toSeconds(checkpoint) -
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(checkpoint)) TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(checkpoint))

View File

@ -322,10 +322,13 @@ public class MainMenu extends BasicGameState {
boolean isTheme = MusicController.isThemePlaying(); boolean isTheme = MusicController.isThemePlaying();
SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU); SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
OsuGroupNode node = menu.setFocus(Opsu.groups.getRandomNode(), -1, true); OsuGroupNode node = menu.setFocus(Opsu.groups.getRandomNode(), -1, true);
if (node != null && !isTheme) boolean sameAudio = false;
if (node != null) {
sameAudio = MusicController.getOsuFile().audioFilename.equals(node.osuFiles.get(0).audioFilename);
if (!isTheme && !sameAudio)
previous.add(node.index); previous.add(node.index);
if (Options.isDynamicBackgroundEnabled() && }
MusicController.getOsuFile() != null && !MusicController.isThemePlaying()) if (Options.isDynamicBackgroundEnabled() && !sameAudio && !MusicController.isThemePlaying())
bgAlpha = 0f; bgAlpha = 0f;
} else if (musicPrevious.contains(x, y)) { } else if (musicPrevious.contains(x, y)) {
if (!previous.isEmpty()) { if (!previous.isEmpty()) {