Next track on trackEnded

(but checks trackended every update...)
Continue playing while minimized(does not fix moving)
start from preview time in songMenu on repeat
This commit is contained in:
fd 2015-03-07 13:29:29 -05:00
parent cf6e87f6f2
commit 11b5c41b46
4 changed files with 13 additions and 4 deletions

View File

@ -161,6 +161,7 @@ public class Opsu extends StateBasedGame {
String[] icons = { "icon16.png", "icon32.png" };
app.setIcons(icons);
app.setForceExit(true);
app.setUpdateOnlyWhenVisible(false);
app.start();

View File

@ -70,8 +70,9 @@ public class MusicController {
* @param osu the OsuFile to play
* @param loop whether or not to loop the track
* @param preview whether to start at the preview time (true) or beginning (false)
* @param reset plays at the preview time even if it has the same preview time as the last
*/
public static void play(final OsuFile osu, final boolean loop, final boolean preview) {
public static void play(final OsuFile osu, final boolean loop, final boolean preview, final boolean reset) {
// new track: load and play
if (lastOsu == null || !osu.audioFilename.equals(lastOsu.audioFilename)) {
reset();
@ -94,7 +95,7 @@ public class MusicController {
}
// new track position: play at position
else if (osu.previewTime != lastOsu.previewTime)
else if (osu.previewTime != lastOsu.previewTime || reset)
playAt(osu.previewTime, loop);
lastOsu = osu;
@ -282,7 +283,7 @@ public class MusicController {
public static void playThemeSong() {
OsuFile osu = Options.getOsuTheme();
if (osu != null) {
play(osu, true, false);
play(osu, true, false, false);
themePlaying = true;
}
}

View File

@ -377,6 +377,9 @@ public class MainMenu extends BasicGameState {
logo.setX(container.getWidth() / 2);
}
}
if (MusicController.trackEnded())
nextTrack();
}
@Override

View File

@ -566,6 +566,10 @@ public class SongMenu extends BasicGameState {
hoverOffset = 0f;
hoverIndex = -1;
}
if (MusicController.trackEnded()) {
OsuFile osu = focusNode.osuFiles.get(focusNode.osuFileIndex);
MusicController.play(osu, false, true, true);
}
}
@Override
@ -1163,7 +1167,7 @@ public class SongMenu extends BasicGameState {
startNode = node;
focusNode = OsuGroupList.get().getNode(node, osuFileIndex);
OsuFile osu = focusNode.osuFiles.get(focusNode.osuFileIndex);
MusicController.play(osu, true, preview);
MusicController.play(osu, false, preview, false);
Utils.loadGlyphs(osu);
// load scores