mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Support switching tracks when music completes
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package forge.sound;
|
||||
|
||||
public interface IAudioMusic {
|
||||
void play();
|
||||
void play(final Runnable onComplete);
|
||||
void pause();
|
||||
void resume();
|
||||
void stop();
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.Map;
|
||||
*
|
||||
*/
|
||||
public class SoundSystem {
|
||||
public static final int DELAY = 30;
|
||||
|
||||
private static final IAudioClip emptySound = new NoSoundClip();
|
||||
private static final Map<SoundEffectType, IAudioClip> loadedClips = new EnumMap<SoundEffectType, IAudioClip>(SoundEffectType.class);
|
||||
@@ -181,7 +182,18 @@ public class SoundSystem {
|
||||
|
||||
try {
|
||||
currentTrack = GuiBase.getInterface().createAudioMusic(filename);
|
||||
currentTrack.play();
|
||||
currentTrack.play(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(SoundSystem.DELAY);
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
changeBackgroundTrack(); //change track when music completes on its own
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.err.println("Unable to load music file: " + filename);
|
||||
|
||||
Reference in New Issue
Block a user