cleaned up code; status bar on main menu shows more info;
This commit is contained in:
@@ -19,7 +19,7 @@ import com.badlogic.gdx.files.FileHandle;
|
||||
*/
|
||||
public class MusicController extends Observable implements OnCompletionListener, Observer {
|
||||
public final class States {
|
||||
public final Integer LOADED = new Integer(0), PLAYING = new Integer(1);
|
||||
public final Integer LOADED = new Integer(0), PLAYING = new Integer(1), PAUSED = new Integer(2);
|
||||
}
|
||||
|
||||
public final States states = new States();
|
||||
@@ -63,6 +63,8 @@ public class MusicController extends Observable implements OnCompletionListener,
|
||||
public void pause() {
|
||||
if (music != null) {
|
||||
music.pause();
|
||||
setChanged();
|
||||
notifyObservers(states.PAUSED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,9 +166,7 @@ public class MusicController extends Observable implements OnCompletionListener,
|
||||
currentlyPlayingIndex = 0;
|
||||
}
|
||||
if (musicList.getTotal() != 0) {
|
||||
FileHandle musicFile = musicList.getAudioFileHandle(currentlyPlayingIndex);
|
||||
if (musicFile == null) return;
|
||||
this.music = Gdx.audio.newMusic(musicFile);
|
||||
this.music = Gdx.audio.newMusic(musicList.getAudioFileHandle(currentlyPlayingIndex));
|
||||
music.setOnCompletionListener(this);
|
||||
|
||||
setChanged();
|
||||
|
@@ -18,7 +18,7 @@ import zero1hd.rhythmbullet.audio.processor.WAVAudioProcessor;
|
||||
*/
|
||||
public class MusicList extends Observable {
|
||||
public final class States {
|
||||
public final Integer LOADING = new Integer(0), COMPLETE = new Integer(1);
|
||||
public final Integer LOADING = new Integer(0), COMPLETE = new Integer(1), EMPTY = new Integer(2);
|
||||
}
|
||||
public States states = new States();
|
||||
private Array<FileHandle> musicList;
|
||||
@@ -73,6 +73,10 @@ public class MusicList extends Observable {
|
||||
setChanged();
|
||||
}
|
||||
|
||||
public String getSearchPath() {
|
||||
return searchPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param file
|
||||
* @return a {@link AudioProcessor} of the given music file. Will return null if theres a format error.
|
||||
@@ -122,14 +126,7 @@ public class MusicList extends Observable {
|
||||
}
|
||||
|
||||
public FileHandle getAudioFileHandle(int index) {
|
||||
FileHandle file = musicList.get(index);
|
||||
if (file != null) {
|
||||
return file;
|
||||
}
|
||||
|
||||
asyncSearch(true);
|
||||
|
||||
return null;
|
||||
return musicList.get(index);
|
||||
}
|
||||
|
||||
public int getIndexOfFileHandle(FileHandle file) {
|
||||
@@ -169,7 +166,11 @@ public class MusicList extends Observable {
|
||||
searched = true;
|
||||
Gdx.app.debug("MusicList", "recursive async search completed.");
|
||||
setChanged();
|
||||
notifyObservers(states.COMPLETE);
|
||||
if (musicList.size != 0) {
|
||||
notifyObservers(states.COMPLETE);
|
||||
} else {
|
||||
notifyObservers(states.EMPTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user