Note that there are some explanatory texts on larger screens.

plurals
  1. POPlay WAV files one after the other in Java
    primarykey
    data
    text
    <p>I'm trying to play a few <a href="http://en.wikipedia.org/wiki/WAV" rel="nofollow noreferrer">WAV</a> files after each other. I tried this method:</p> <pre><code>for (String file : audioFiles) { new AePlayWave(file).start(); } </code></pre> <p>But that plays them all at the same time. So I need a function that looks like this:</p> <pre><code>public void play(Vector&lt;String&gt; audioFiles); </code></pre> <p>The vector contains the files, for example: <code>"test1.wav"</code>,<code>"test2.wav"</code></p> <p>I have been looking for over four hours, but I can't seem to find a working solution :(</p> <p>I also tried concatenating the WAV files to one AudioInputStream. It doesn't give any compiler errors, but the sound is totally messed up. Code:</p> <pre><code>public static AudioInputStream concat(Vector&lt;String&gt; files) throws UnsupportedAudioFileException, IOException { AudioInputStream total = AudioSystem.getAudioInputStream(new File(files.get(0))); for (int i = 1; i &lt; 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; } </code></pre> <p><strong>Edit</strong></p> <p>Even if I try to put the two first files together, it fails:</p> <pre><code>public static AudioInputStream concat(Vector&lt;String&gt; 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; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload