Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From what i gather form your description, you are pressing a stop button on your GUI and this calls <code>Music.stopMusic()</code>. The result is that the audio clip stops playing, but you are still waiting 3 seconds before you GUI becomes responsive.</p> <p>This is because the call you are making in <code>Music.stopMusic()</code> makes native calls to I/O resources, and this should not be called in the EDT. You should look at running up a worker thread to do this:</p> <pre><code>Thread t = new Thread(new Runnable() { public void run() { Music.stop(); } }); t.start(); </code></pre> <p>Or look to using a <a href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/worker.html" rel="nofollow">SwingWorker</a>. </p> <p>Interestingly, though I am not sure which implementation of <code>Clip</code> is returned, but a quick look at <a href="http://javasourcecode.org/html/open-source/jdk/jdk-6u23/com/sun/media/sound/MixerClip.java.html" rel="nofollow"><code>MixerClip</code></a> shows a call to a native library, and then perhaps the smoking gun in your predicament- a 3 second wait for a callback!</p> <pre><code>// stop the sample. this invalidates the sample voice id. nStop(id); // wait for the callback synchronized(lock) { if (id!=0) { try { //long time=System.currentTimeMillis(); lock.wait(3000); //if (System.currentTimeMillis()-time &gt; 2500) { //System.out.println(" WAITING TIMED OUT!"); System.out.flush(); //id=0; //} } catch (InterruptedException e) { } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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