List of usage examples for javax.sound.sampled Port open
void open() throws LineUnavailableException;
From source file:org.eclipse.smarthome.io.javasound.internal.JavaSoundAudioSink.java
private void runVolumeCommand(Closure closure) { Mixer.Info[] infos = AudioSystem.getMixerInfo(); for (Mixer.Info info : infos) { Mixer mixer = AudioSystem.getMixer(info); if (mixer.isLineSupported(Port.Info.SPEAKER)) { Port port; try { port = (Port) mixer.getLine(Port.Info.SPEAKER); port.open(); if (port.isControlSupported(FloatControl.Type.VOLUME)) { FloatControl volume = (FloatControl) port.getControl(FloatControl.Type.VOLUME); closure.execute(volume); }/*from w ww . j a v a2s .c o m*/ port.close(); } catch (LineUnavailableException e) { logger.error("Cannot access master volume control", e); } } } }
From source file:org.openhab.io.javasound.internal.JavaSoundAudioSink.java
private void runVolumeCommand(Closure closure) { Mixer.Info[] infos = AudioSystem.getMixerInfo(); for (Mixer.Info info : infos) { Mixer mixer = AudioSystem.getMixer(info); if (mixer.isLineSupported(Port.Info.SPEAKER)) { Port port; try { port = (Port) mixer.getLine(Port.Info.SPEAKER); port.open(); if (port.isControlSupported(FloatControl.Type.VOLUME)) { FloatControl volume = (FloatControl) port.getControl(FloatControl.Type.VOLUME); closure.execute(volume); }/*w ww .j a va 2 s .c o m*/ port.close(); } catch (LineUnavailableException e) { LOGGER.error("Cannot access master volume control", e); } } } }
From source file:org.openhab.io.multimedia.actions.Audio.java
private static void runVolumeCommand(Closure closure) { Mixer.Info[] infos = AudioSystem.getMixerInfo(); for (Mixer.Info info : infos) { Mixer mixer = AudioSystem.getMixer(info); if (mixer.isLineSupported(Port.Info.SPEAKER)) { Port port; try { port = (Port) mixer.getLine(Port.Info.SPEAKER); port.open(); if (port.isControlSupported(FloatControl.Type.VOLUME)) { FloatControl volume = (FloatControl) port.getControl(FloatControl.Type.VOLUME); closure.execute(volume); }/*from www .j av a 2 s . c om*/ port.close(); } catch (LineUnavailableException e) { logger.error("Cannot access master volume control", e); } } } }