javax.sound.sampled.LineEvent Java Examples
The following examples show how to use
javax.sound.sampled.LineEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractLine.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * This method sets the open state and generates * events if it changes. */ final void setOpen(boolean open) { if (Printer.trace) Printer.trace("> "+getClass().getName()+" (AbstractLine): setOpen(" + open + ") this.open: " + this.open); boolean sendEvents = false; long position = getLongFramePosition(); synchronized (this) { if (this.open != open) { this.open = open; sendEvents = true; } } if (sendEvents) { if (open) { sendEvents(new LineEvent(this, LineEvent.Type.OPEN, position)); } else { sendEvents(new LineEvent(this, LineEvent.Type.CLOSE, position)); } } if (Printer.trace) Printer.trace("< "+getClass().getName()+" (AbstractLine): setOpen(" + open + ") this.open: " + this.open); }
Example #2
Source File: Utils.java From ripme with MIT License | 6 votes |
/** * Plays a sound from a file. * * @param filename Path to the sound file */ public static void playSound(String filename) { URL resource = ClassLoader.getSystemClassLoader().getResource(filename); try { final Clip clip = (Clip) AudioSystem.getLine(new Line.Info(Clip.class)); clip.addLineListener(event -> { if (event.getType() == LineEvent.Type.STOP) { clip.close(); } }); clip.open(AudioSystem.getAudioInputStream(resource)); clip.start(); } catch (Exception e) { LOGGER.error("Failed to play sound " + filename, e); } }
Example #3
Source File: UI.java From txtUML with Eclipse Public License 1.0 | 6 votes |
private void playSirenSound() { try { File soundFile = new File(sirenFile); AudioInputStream soundIn = AudioSystem.getAudioInputStream(soundFile); AudioFormat format = soundIn.getFormat(); DataLine.Info info = new DataLine.Info(Clip.class, format); clip = (Clip) AudioSystem.getLine(info); clip.addLineListener(new LineListener() { @Override public void update(LineEvent event) { if (event.getType() == LineEvent.Type.STOP) { soundOn = false; } } }); clip.open(soundIn); clip.start(); soundOn = true; } catch (Exception e) { e.printStackTrace(); } }
Example #4
Source File: AbstractLine.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * This method sets the open state and generates * events if it changes. */ final void setOpen(boolean open) { if (Printer.trace) Printer.trace("> "+getClass().getName()+" (AbstractLine): setOpen(" + open + ") this.open: " + this.open); boolean sendEvents = false; long position = getLongFramePosition(); synchronized (this) { if (this.open != open) { this.open = open; sendEvents = true; } } if (sendEvents) { if (open) { sendEvents(new LineEvent(this, LineEvent.Type.OPEN, position)); } else { sendEvents(new LineEvent(this, LineEvent.Type.CLOSE, position)); } } if (Printer.trace) Printer.trace("< "+getClass().getName()+" (AbstractLine): setOpen(" + open + ") this.open: " + this.open); }
Example #5
Source File: AbstractLine.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * This method sets the open state and generates * events if it changes. */ final void setOpen(boolean open) { if (Printer.trace) Printer.trace("> "+getClass().getName()+" (AbstractLine): setOpen(" + open + ") this.open: " + this.open); boolean sendEvents = false; long position = getLongFramePosition(); synchronized (this) { if (this.open != open) { this.open = open; sendEvents = true; } } if (sendEvents) { if (open) { sendEvents(new LineEvent(this, LineEvent.Type.OPEN, position)); } else { sendEvents(new LineEvent(this, LineEvent.Type.CLOSE, position)); } } if (Printer.trace) Printer.trace("< "+getClass().getName()+" (AbstractLine): setOpen(" + open + ") this.open: " + this.open); }
Example #6
Source File: AbstractDataLine.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * This method sets the started state and generates * events if it changes. */ final void setStarted(boolean started) { boolean sendEvents = false; long position = getLongFramePosition(); synchronized (this) { if (this.started != started) { this.started = started; sendEvents = true; } } if (sendEvents) { if (started) { sendEvents(new LineEvent(this, LineEvent.Type.START, position)); } else { sendEvents(new LineEvent(this, LineEvent.Type.STOP, position)); } } }
Example #7
Source File: AbstractLine.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * This method sets the open state and generates * events if it changes. */ final void setOpen(boolean open) { if (Printer.trace) Printer.trace("> "+getClass().getName()+" (AbstractLine): setOpen(" + open + ") this.open: " + this.open); boolean sendEvents = false; long position = getLongFramePosition(); synchronized (this) { if (this.open != open) { this.open = open; sendEvents = true; } } if (sendEvents) { if (open) { sendEvents(new LineEvent(this, LineEvent.Type.OPEN, position)); } else { sendEvents(new LineEvent(this, LineEvent.Type.CLOSE, position)); } } if (Printer.trace) Printer.trace("< "+getClass().getName()+" (AbstractLine): setOpen(" + open + ") this.open: " + this.open); }
Example #8
Source File: WaveEngine.java From javagame with MIT License | 6 votes |
public void update(LineEvent event) { // �X�g�b�v���Ō�܂ōĐ����ꂽ�ꍇ if (event.getType() == LineEvent.Type.STOP) { Clip clip = (Clip) event.getSource(); clip.stop(); clip.setFramePosition(0); // �Đ��ʒu���ŏ��ɖ߂� } }
Example #9
Source File: AbstractLine.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * This method sets the open state and generates * events if it changes. */ final void setOpen(boolean open) { if (Printer.trace) Printer.trace("> "+getClass().getName()+" (AbstractLine): setOpen(" + open + ") this.open: " + this.open); boolean sendEvents = false; long position = getLongFramePosition(); synchronized (this) { if (this.open != open) { this.open = open; sendEvents = true; } } if (sendEvents) { if (open) { sendEvents(new LineEvent(this, LineEvent.Type.OPEN, position)); } else { sendEvents(new LineEvent(this, LineEvent.Type.CLOSE, position)); } } if (Printer.trace) Printer.trace("< "+getClass().getName()+" (AbstractLine): setOpen(" + open + ") this.open: " + this.open); }
Example #10
Source File: IsRunningHang.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void test(final AudioFormat format, final byte[] data) throws Exception { final Line.Info info = new DataLine.Info(Clip.class, format); final Clip clip = (Clip) AudioSystem.getLine(info); go = new CountDownLatch(1); clip.addLineListener(event -> { if (event.getType().equals(LineEvent.Type.START)) { go.countDown(); } }); clip.open(format, data, 0, data.length); clip.start(); go.await(); while (clip.isRunning()) { // This loop should not hang } while (clip.isActive()) { // This loop should not hang } clip.close(); }
Example #11
Source File: ClipLinuxCrash2.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void update(LineEvent e) { if (e.getType() == LineEvent.Type.STOP) { stopOccured++; out(" Test program: receives STOP event for clip="+clip.toString()+" no."+stopOccured); out(" Test program: Calling close() in event dispatcher thread"); clip.close(); synchronized (lock) { lock.notifyAll(); } } else if (e.getType() == LineEvent.Type.CLOSE) { out(" Test program: receives CLOSE event for "+clip.toString()); synchronized (lock) { lock.notifyAll(); } } else if (e.getType() == LineEvent.Type.START) { out(" Test program: receives START event for "+clip.toString()); } else if (e.getType() == LineEvent.Type.OPEN) { out(" Test program: receives OPEN event for "+clip.toString()); } }
Example #12
Source File: WaveEngine.java From javagame with MIT License | 6 votes |
public void update(LineEvent event) { // �X�g�b�v���Ō�܂ōĐ����ꂽ�ꍇ if (event.getType() == LineEvent.Type.STOP) { Clip clip = (Clip) event.getSource(); clip.stop(); clip.setFramePosition(0); // �Đ��ʒu���ŏ��ɖ߂� } }
Example #13
Source File: SoftMixingMixer.java From hottub with GNU General Public License v2.0 | 5 votes |
private void sendEvent(LineEvent event) { if (listeners.size() == 0) return; LineListener[] listener_array = listeners .toArray(new LineListener[listeners.size()]); for (LineListener listener : listener_array) { listener.update(event); } }
Example #14
Source File: SoftMixingDataLine.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
final void sendEvent(LineEvent event) { if (listeners.size() == 0) return; LineListener[] listener_array = listeners .toArray(new LineListener[listeners.size()]); for (LineListener listener : listener_array) { listener.update(event); } }
Example #15
Source File: SoftMixingDataLine.java From hottub with GNU General Public License v2.0 | 5 votes |
final void sendEvent(LineEvent event) { if (listeners.size() == 0) return; LineListener[] listener_array = listeners .toArray(new LineListener[listeners.size()]); for (LineListener listener : listener_array) { listener.update(event); } }
Example #16
Source File: AbstractDataLine.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * This method sets the started state and generates * events if it changes. */ final void setStarted(boolean started) { if (Printer.trace) Printer.trace("> AbstractDataLine: setStarted(" + started + ")"); boolean sendEvents = false; long position = getLongFramePosition(); synchronized (this) { //if (Printer.debug) Printer.debug(" AbstractDataLine: setStarted: this.started: " + this.started); //if (Printer.debug) Printer.debug(" started: " + started); if (this.started != started) { this.started = started; sendEvents = true; } } //if (Printer.debug) Printer.debug(" this.started: " + this.started); //if (Printer.debug) Printer.debug(" sendEvents: " + sendEvents); if (sendEvents) { if (started) { sendEvents(new LineEvent(this, LineEvent.Type.START, position)); } else { sendEvents(new LineEvent(this, LineEvent.Type.STOP, position)); } } if (Printer.trace) Printer.trace("< AbstractDataLine: setStarted completed"); }
Example #17
Source File: AbstractDataLine.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * This method sets the started state and generates * events if it changes. */ final void setStarted(boolean started) { if (Printer.trace) Printer.trace("> AbstractDataLine: setStarted(" + started + ")"); boolean sendEvents = false; long position = getLongFramePosition(); synchronized (this) { //if (Printer.debug) Printer.debug(" AbstractDataLine: setStarted: this.started: " + this.started); //if (Printer.debug) Printer.debug(" started: " + started); if (this.started != started) { this.started = started; sendEvents = true; } } //if (Printer.debug) Printer.debug(" this.started: " + this.started); //if (Printer.debug) Printer.debug(" sendEvents: " + sendEvents); if (sendEvents) { if (started) { sendEvents(new LineEvent(this, LineEvent.Type.START, position)); } else { sendEvents(new LineEvent(this, LineEvent.Type.STOP, position)); } } if (Printer.trace) Printer.trace("< AbstractDataLine: setStarted completed"); }
Example #18
Source File: SoftMixingMixer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private void sendEvent(LineEvent event) { if (listeners.size() == 0) return; LineListener[] listener_array = listeners .toArray(new LineListener[listeners.size()]); for (LineListener listener : listener_array) { listener.update(event); } }
Example #19
Source File: AbstractDataLine.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * This method sets the started state and generates * events if it changes. */ final void setStarted(boolean started) { if (Printer.trace) Printer.trace("> AbstractDataLine: setStarted(" + started + ")"); boolean sendEvents = false; long position = getLongFramePosition(); synchronized (this) { //if (Printer.debug) Printer.debug(" AbstractDataLine: setStarted: this.started: " + this.started); //if (Printer.debug) Printer.debug(" started: " + started); if (this.started != started) { this.started = started; sendEvents = true; } } //if (Printer.debug) Printer.debug(" this.started: " + this.started); //if (Printer.debug) Printer.debug(" sendEvents: " + sendEvents); if (sendEvents) { if (started) { sendEvents(new LineEvent(this, LineEvent.Type.START, position)); } else { sendEvents(new LineEvent(this, LineEvent.Type.STOP, position)); } } if (Printer.trace) Printer.trace("< AbstractDataLine: setStarted completed"); }
Example #20
Source File: SoftMixingMixer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private void sendEvent(LineEvent event) { if (listeners.size() == 0) return; LineListener[] listener_array = listeners .toArray(new LineListener[listeners.size()]); for (LineListener listener : listener_array) { listener.update(event); } }
Example #21
Source File: SoftMixingMixer.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void sendEvent(LineEvent event) { if (listeners.size() == 0) return; LineListener[] listener_array = listeners .toArray(new LineListener[listeners.size()]); for (LineListener listener : listener_array) { listener.update(event); } }
Example #22
Source File: SoftMixingDataLine.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
final void sendEvent(LineEvent event) { if (listeners.size() == 0) return; LineListener[] listener_array = listeners .toArray(new LineListener[listeners.size()]); for (LineListener listener : listener_array) { listener.update(event); } }
Example #23
Source File: SoftMixingDataLine.java From Bytecoder with Apache License 2.0 | 5 votes |
final void sendEvent(LineEvent event) { if (listeners.size() == 0) return; LineListener[] listener_array = listeners .toArray(new LineListener[listeners.size()]); for (LineListener listener : listener_array) { listener.update(event); } }
Example #24
Source File: SoftMixingDataLine.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
final void sendEvent(LineEvent event) { if (listeners.size() == 0) return; LineListener[] listener_array = listeners .toArray(new LineListener[listeners.size()]); for (LineListener listener : listener_array) { listener.update(event); } }
Example #25
Source File: SoftMixingMixer.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private void sendEvent(LineEvent event) { if (listeners.size() == 0) return; LineListener[] listener_array = listeners .toArray(new LineListener[listeners.size()]); for (LineListener listener : listener_array) { listener.update(event); } }
Example #26
Source File: SoftMixingDataLine.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
final void sendEvent(LineEvent event) { if (listeners.size() == 0) return; LineListener[] listener_array = listeners .toArray(new LineListener[listeners.size()]); for (LineListener listener : listener_array) { listener.update(event); } }
Example #27
Source File: SoftMixingDataLine.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
final void sendEvent(LineEvent event) { if (listeners.size() == 0) return; LineListener[] listener_array = listeners .toArray(new LineListener[listeners.size()]); for (LineListener listener : listener_array) { listener.update(event); } }
Example #28
Source File: AbstractDataLine.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * This method sets the started state and generates * events if it changes. */ final void setStarted(boolean started) { if (Printer.trace) Printer.trace("> AbstractDataLine: setStarted(" + started + ")"); boolean sendEvents = false; long position = getLongFramePosition(); synchronized (this) { //if (Printer.debug) Printer.debug(" AbstractDataLine: setStarted: this.started: " + this.started); //if (Printer.debug) Printer.debug(" started: " + started); if (this.started != started) { this.started = started; sendEvents = true; } } //if (Printer.debug) Printer.debug(" this.started: " + this.started); //if (Printer.debug) Printer.debug(" sendEvents: " + sendEvents); if (sendEvents) { if (started) { sendEvents(new LineEvent(this, LineEvent.Type.START, position)); } else { sendEvents(new LineEvent(this, LineEvent.Type.STOP, position)); } } if (Printer.trace) Printer.trace("< AbstractDataLine: setStarted completed"); }
Example #29
Source File: Sound.java From Lunar with MIT License | 5 votes |
@Override public void update(LineEvent event) { LineEvent.Type type = event.getType(); if (type == LineEvent.Type.STOP) { clip.close(); } }
Example #30
Source File: AudioFilePlayer.java From JVoiceXML with GNU Lesser General Public License v2.1 | 5 votes |
/** * {@inheritDoc} */ @Override public void update(final LineEvent event) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("line updated: " + event.getType()); } if ((event.getType() == LineEvent.Type.CLOSE) || (event.getType() == LineEvent.Type.STOP)) { sem.release(); } }