public void run() { System.err.println("Timer task running"); if (!clip.isActive() // already stopped? || clip.getFramePosition() >= endFrame) { System.err.println("Timer task stopping clip."); clip.stop(); this.cancel(); } } }
public void run() { System.err.println("Timer task running"); if (!clip.isActive() // already stopped? || clip.getFramePosition() >= endFrame) { System.err.println("Timer task stopping clip."); clip.stop(); this.cancel(); } } }
/** * Stop wav play back * */ public static void stopWavFile() { m_clip.stop(); m_clip.flush(); m_clip.close(); }
/** * Stop wav play back * */ public static void stopWavFile() { m_clip.stop(); m_clip.flush(); m_clip.close(); }
public void actionPerformed(ActionEvent e) { synchronized (clip) { if (clip.isActive()) { System.err.println("Stopping clip."); clip.stop(); } else { System.err.println("Rewinding clip."); if (Double.isNaN(positionCursor.x)) { // no cursor, play from start clip.setFramePosition(0); } else { // play from cursor position clip.setFramePosition(X2indexX(positionCursor.x)); } if (!Double.isNaN(rangeCursor.x)) { // range set? System.err.println("Setting timer task"); int endFrame = X2indexX(rangeCursor.x); timer.schedule(new ClipObserver(clip, endFrame), 50, 50); } System.err.println("Starting clip."); clip.start(); } } } });
public void actionPerformed(ActionEvent e) { synchronized (clip) { if (clip.isActive()) { System.err.println("Stopping clip."); clip.stop(); } else { System.err.println("Rewinding clip."); if (Double.isNaN(positionCursor.x)) { // no cursor, play from start clip.setFramePosition(0); } else { // play from cursor position clip.setFramePosition(X2indexX(positionCursor.x)); } if (!Double.isNaN(rangeCursor.x)) { // range set? System.err.println("Setting timer task"); int endFrame = X2indexX(rangeCursor.x); timer.schedule(new ClipObserver(clip, endFrame), 50, 50); } System.err.println("Starting clip."); clip.start(); } } } });
public void stop(Sound sound) { Clip clip = activeClips.get(sound); if(clip != null) { clip.stop(); } }
public void pause() { c.stop(); playing = false; }
/** * Stops playing the clip. */ public void stop() { if (clip == null) return; clip.stop(); }
@Override protected void stopImpl() { impl.stop(); impl.flush(); }
private Clip next() { Clip c = clips[idx]; idx = (idx + 1) % clips.length; c.stop(); c.setFramePosition(0); return c; } }
@Override protected void stopImpl() { impl.stop(); impl.flush(); }
private void playClip(Clip clip, long duration) { clip.loop(Clip.LOOP_CONTINUOUSLY); try { Thread.sleep(duration); } catch (InterruptedException e) { // Ignore Exception } clip.stop(); }
public synchronized void stop() { if (clip != null) { clip.stop(); clip.close(); clip = null; } }
@Override protected void stopImpl() { impl.stop(); impl.flush(); }
/** Stop playing the sound, but retain the current position */ public void stop() { timer.stop(); clip.stop(); play.setText(Messages.getString("AuView.play")); //$NON-NLS-1$ playing = false; }
@Override public void stop() { if (isPlaying()) { clip.stop(); } } }
/** * Stops the background music. */ public void stopBackgroundMusic() { Clip c = getSounds().getSound("background"); if (c != null) { c.stop(); } }
/** * Plays the clip from the beginning. */ public void play() { if (clip == null) return; // applet audio clip resets to beginning when played again clip.stop(); clip.setFramePosition(0); clip.start(); }
File soundFile = new File("path_to_file\\doorbell.wav"); Clip clip = AudioSystem.getClip(); AudioInputStream inputStream = AudioSystem.getAudioInputStream(soundFile); clip.open(inputStream); clip.stop();//to avoid overlaps clip.setFramePosition(0); clip.start();