title: How to start a sound that is already playing?
body: <p>I'm making game extension to play some sounds. The sounds may be triggered at random times, which means that the same sound may be triggered twice with very little time apart. In this case, the sound should start playing even though it is already playing (if that makes sense).</p>
  
  <p>I'm using a Clip to play the sound. This means that I have to "rewind" the clip before playing it. It seems, since it's the same clip, that it stops playing before re-starting. What I want is for it to continue playing, and play the same clip "on top" of the previos one. See this example:</p>
  
  <pre><code>import java.io.File;
  import javax.sound.sampled.AudioInputStream;
  import javax.sound.sampled.AudioSystem;
  import javax.sound.sampled.Clip;
  
  public class JavaApplication {
  
      public static void main(String[] args) throws Exception {
          File file = new File(JavaApplication.class.getResource("1.wav").getPath());
          AudioInputStream inputStream = AudioSystem.getAudioInputStream(file);
  
          Clip clip = AudioSystem.getClip();
          clip.open(inputStream);
          clip.setFramePosition(0);
          clip.start(); // The sound is 300 ms long
          Thread.sleep(150); // Let it play for 150 ms
          clip.setFramePosition(0); // Attempt to start it from the beginning, without stopping it
          clip.start();
          Thread.sleep(1000);
      }
  }
  </code></pre>