1 Reply Latest reply: Dec 6, 2010 12:05 PM by captfoss RSS

    Java playback of multiple wav files in sequence - without overlap

    821449
      Hi there

      I am asking for suggestions on how to do simple consecutive playback of multiple wavefiles using java. Right now I have each wavefile loaded into a clip, and the playback almost works, but with occasional errors where two or more of the files are played back simultaneously. I am doing busy-waiting using the clip.isActive() method in a while-loop in order to detect when a clip has finished playing so that the next one can start. I know that there are most likely some smarter methods of doing this, and I have tried some of them - e.g. linelistener but without getting it to work. If anyone can supply me with some example code on how to do this the right way, or could point me to some literature, it would be greatly appreciated.

      Thx in advance.
      Jacob
        • 1. Re: Java playback of multiple wav files in sequence - without overlap
          captfoss
          http://www.jsresources.org/examples/SimpleAudioPlayer.html

          That example plays a file by opening it with an AudioInputStream and copying the contents to a SourceDataLine to play it...

          It can be easily modified to allow for multiple files to be opened & copied to a single SDL, and is what I'd consider the "proper" way to do it. Clips are mostly useful for things like making a button go "beep" and things of that nature. Not especially useful for normal multimedia applications.