Running sounds in succession

I have been trying to get some code together that will play one sound, and when that sound is done, play another sound but I have been unable to do so. I was hoping that someone here could point out the error in my logic and or code so that I can get it running.

//The calling method

private void playSound(String soundString)

{

try

{

Clip theClip = getClip(getURL(soundString));

SoundThread st = new SoundThread(theClip, 0);

st.playSound();

while (st.isDonePlaying() == false)

{

Thread.sleep(20);

}

} catch (Exception ex)

{

ex.printStackTrace();

}

}

//The sounds thread class

import javax.sound.sampled.*;

public class SoundThread extends Thread

{

private Clip soundClip = null;

private int soundIndex = 0;

private int loopCount = 0;

private boolean donePlaying = false;

public SoundThread(Clip clip, int index)

{

soundIndex = index;

soundClip = clip;

soundClip.stop();

soundClip.flush();

soundClip.setFramePosition(0);

soundClip.setLoopPoints(0, -1);

setPriority(Thread.MIN_PRIORITY);

}

public void playSound()

{

loopCount = 0;

start();

}

public void loopSound()

{

loopCount = Clip.LOOP_CONTINUOUSLY;

start();

}

public void stopSound()

{

soundClip.stop();

soundClip.flush();

soundClip.setFramePosition(0);

donePlaying = true;

}

public int getSoundIndex()

{

return soundIndex;

}

public boolean isDonePlaying()

{

return donePlaying;

}

public void run()

{

soundClip.loop(loopCount);

donePlaying = true;

}

}

[1809 byte] By [Dauntalusa] at [2007-10-2 6:50:04]
# 1
You can't do that with Clip, as it starts a separate thread to play each, which (can) cause Multiple Clips to play at once.To play sounds serially, use the Java Sound API.
ChuckBinga at 2007-7-16 13:59:01 > top of Java-index,Java Essentials,Java Programming...