Example #1
0
 // sets volume for player
 private void setVolume(int value) {
   try {
     VolumeControl c = (VolumeControl) player.getControl("VolumeControl");
     if ((null != c) && (0 < value)) {
       c.setLevel(value);
     }
   } catch (Exception e) {
   }
 }
  /** Do the actual muting/unmuting. */
  private void doRun() {
    if (call != null) {
      OperationSetBasicTelephony<?> telephony =
          call.getProtocolProvider().getOperationSet(OperationSetBasicTelephony.class);

      mute = !mute;
      telephony.setMute(call, mute);

      // We make sure that the button state corresponds to the mute state.
      setSelected(mute);

      // If we unmute the microphone and the volume control is set to min,
      // make sure that the volume control is restored to the initial
      // state.
      if (!mute && volumeControl.getVolume() == volumeControl.getMinValue()) {
        volumeControl.setVolume((volumeControl.getMaxValue() - volumeControl.getMinValue()) / 2);
      }
    }
  }
  /**
   * Volume control used by the button.
   *
   * @return volume control used by the button.
   */
  private VolumeControl getVolumeControl() {
    VolumeControl volumeControl = GuiActivator.getMediaService().getInputVolumeControl();

    volumeControl.addVolumeChangeListener(this);
    return volumeControl;
  }