Hi,
Am using the code from TestMusicQueue to get a couple of tracks together that can be played one after the other.
public static void main(String[] args) throws Exception {
String tracksDir = "dir/";
List<String> tracks = new ArrayList<String>();
tracks.add("ogg1.ogg");
tracks.add("ogg2.ogg");
Collections.shuffle(tracks);
try {
ResourceLocatorTool.addResourceLocator(
ResourceLocatorTool.TYPE_AUDIO,
new SimpleResourceLocator(TestMusicQueue.class
.getClassLoader().getResource(tracksDir + tracks.get(0))));
} catch (URISyntaxException e) {
e.printStackTrace();
}
AudioSystem audio = AudioSystem.getSystem();
final List<AudioTrack> loaded = new ArrayList<AudioTrack>();
for (String track : tracks) {
AudioTrack at = audio.createAudioTrack(track, true);
at.setType(TrackType.MUSIC);
at.setRelative(true);
at.setTargetVolume(1.0f);
at.setLooping(false);
loaded.add(at);
}
for (AudioTrack at : loaded) {
audio.getMusicQueue().addTrack(at);
}
audio.getMusicQueue().setRepeatType(RepeatType.ALL);
audio.getMusicQueue().setCrossfadeinTime(2.5f);
audio.getMusicQueue().setCrossfadeoutTime(2.5f);
audio.getMusicQueue().play();
AudioSystem.getSystem().update();
}
Am using this in a game loop in my app, only problem is, it plays the first track and then goes no further. Is this a common problem or is there something missing?
Thanks, :)