List of usage examples for javax.sound.sampled Clip isActive
boolean isActive();
From source file:SimpleSoundPlayer.java
public void playSound() { midiEOM = audioEOM = bump = false;//from w w w . ja va 2 s. com if (currentSound instanceof Sequence || currentSound instanceof BufferedInputStream && thread != null) { sequencer.start(); while (!midiEOM && thread != null && !bump) { try { thread.sleep(99); } catch (Exception e) { break; } } sequencer.stop(); sequencer.close(); } else if (currentSound instanceof Clip) { Clip clip = (Clip) currentSound; clip.start(); try { thread.sleep(99); } catch (Exception e) { } while ((paused || clip.isActive()) && thread != null && !bump) { try { thread.sleep(99); } catch (Exception e) { break; } } clip.stop(); clip.close(); } currentSound = null; }
From source file:edu.tsinghua.lumaqq.Sounder.java
/** * //from w w w .j av a 2 s.co m */ private void playSound() { // midi? midiEOM = false; if (currentSound instanceof Sequence || currentSound instanceof BufferedInputStream) { /* ?Sequence? */ if (sequencer == null) openSequencer(); sequencer.start(); while (!midiEOM) { try { sleep(99); } catch (Exception e) { break; } } sequencer.stop(); sequencer.close(); } else if (currentSound instanceof Clip) { /* Clip */ Clip clip = (Clip) currentSound; clip.start(); try { sleep(99); } catch (Exception e) { log.error(e.getMessage()); } while (clip.isActive()) { try { sleep(99); } catch (Exception e) { break; } } clip.stop(); clip.close(); } currentSound = null; }
From source file:org.openhab.io.multimedia.actions.Audio.java
private static void playInThread(final Clip clip) { // run in new thread new Thread() { public void run() { try { clip.start();// ww w . j a v a2 s.c om while (clip.isActive()) { sleep(1000L); } clip.close(); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } } }.start(); }