import net.pterodactylus.sonitus.data.Sink;
import net.pterodactylus.sonitus.data.Source;
import net.pterodactylus.sonitus.data.controller.Fader;
+import net.pterodactylus.sonitus.data.controller.Switch;
import com.google.common.base.Preconditions;
/** The volume fader. */
private final Fader volumeFader;
+ /** The “mute” switch. */
+ private final Switch muteSwitch;
+
/** The current metadata. */
private Metadata metadata;
}
}
};
+ muteSwitch = new Switch() {
+
+ private float previousValue;
+
+ @Override
+ protected void valueSet(int value) {
+ if (sourceDataLine != null) {
+ FloatControl volumeControl = (FloatControl) sourceDataLine.getControl(VOLUME);
+ if (value == 1) {
+ previousValue = volumeControl.getValue();
+ volumeControl.setValue(0);
+ } else {
+ volumeControl.setValue(previousValue);
+ }
+ }
+ }
+ };
}
//
@Override
public List<Controller> controllers() {
- return Arrays.<Controller>asList(volumeFader);
+ return Arrays.<Controller>asList(volumeFader, muteSwitch);
}
//