I'm trying to play a few WAV files after each other. I tried this method:
for (String file : audioFiles) {
new AePlayWave(file).start();
}
but that plays them all at the same time. So i need a function that looks like this:
public void play(Vector<String> audioFiles);
the vector contains the files, eg: "test1.wav"
,"test2.wav"
been looking for over 4 hours, but I can't seem to find a working solution :(
I also tried concatenating the WAV files to 1 AudioInputStream. It doesn't give any compiler errors but the sound is totally messed up. Code:
public static AudioInputStream concat(Vector<String> files) throws UnsupportedAudioFileException, IOException {
AudioInputStream total = AudioSystem.getAudioInputStream(new File(files.get(0)));
for (int i = 1; i < files.size(); i++) {
AudioInputStream clip = AudioSystem.getAudioInputStream(new File(files.get(i)));
total = new AudioInputStream(new SequenceInputStream(total, clip),
total.getFormat(),
total.getFrameLength() + clip.getFrameLength());
}
return total;
}
edit even if i try to put the 2 first files together it fails:
public static AudioInputStream concat(Vector files) throws UnsupportedAudioFileException, IOException { AudioInputStream clip1 = AudioSystem.getAudioInputStream(new File(files.get(0))); AudioInputStream clip2 = AudioSystem.getAudioInputStream(new File(files.get(1)));
AudioInputStream total = new AudioInputStream( new SequenceInputStream(clip1, clip2), clip1.getFormat(), clip1.getFrameLength() + clip2.getFrameLength());
return total; }