Get and set the volume settings.

    Passing 'mute' as new volume will mute the volume,
    'unmute' removes it.
320882
async def volume(dev: Device, volume, output):
    
    vol = None
    vol_controls = await dev.get_volume_information()
    if output is not None:
        click.echo("Using output: %s" % output)
        output_uri = (await dev.get_zone(output)).uri
        for v in vol_controls:
            if v.output == output_uri:
                vol = v
                break
    else:
        vol = vol_controls[0]

    if vol is None:
        err("Unable to find volume controller: %s" % output)
        return

    if volume and volume == "mute":
        click.echo("Muting")
        await vol.set_mute(True)
    elif volume and volume == "unmute":
        click.echo("Unmuting")
        await vol.set_mute(False)
    elif volume:
        click.echo("Setting volume to %s" % volume)
        await vol.set_volume(volume)

    if output is not None:
        click.echo(vol)
    else:
        [click.echo(x) for x in vol_controls]
706029
def _on_group_mute(self, data):
        """"""
        self._groups.get(data.get('id')).update_mute(data)
1146286
function(muted, id) {
      var self = this;

      // If the sound hasn't loaded, add it to the load queue to mute when capable.
      if (self._state !== 'loaded'|| self._playLock) {
        self._queue.push({
          event: 'mute',
          action: function() {
            self.mute(muted, id);
          }
        });

        return self;
      }

      // If applying mute/unmute to all sounds, update the group's value.
      if (typeof id === 'undefined') {
        if (typeof muted === 'boolean') {
          self._muted = muted;
        } else {
          return self._muted;
        }
      }

      // If no id is passed, get all ID's to be muted.
      var ids = self._getSoundIds(id);

      for (var i=0; i<ids.length; i++) {
        // Get the sound.
        var sound = self._soundById(ids[i]);

        if (sound) {
          sound._muted = muted;

          // Cancel active fade and set the volume to the end value.
          if (sound._interval) {
            self._stopFade(sound._id);
          }

          if (self._webAudio && sound._node) {
            sound._node.gain.setValueAtTime(muted ? 0 : sound._volume, Howler.ctx.currentTime);
          } else if (sound._node) {
            sound._node.muted = Howler._muted ? true : muted;
          }

          self._emit('mute', sound._id);
        }
      }

      return self;
    }
544411
def stop_volume(name, force=False):
    '''
    
    '''
    volinfo = info()
    if name not in volinfo:
        log.error('Cannot stop non-existing volume %s', name)
        return False
    if int(volinfo[name]['status']) != 1:
        log.warning('Attempt to stop already stopped volume %s', name)
        return True

    cmd = 'volume stop {0}'.format(name)
    if force:
        cmd += ' force'

    return _gluster(cmd)
894132
def on_click(self, event):
        
        button = event["button"]
        # volume up
        if button == self.button_up:
            self.backend.volume_up(self.volume_delta)
        # volume down
        elif button == self.button_down:
            self.backend.volume_down(self.volume_delta)
        # toggle mute
        elif button == self.button_mute:
            self.backend.toggle_mute()
118247
def set_output_volume(volume):
    '''
    
    '''
    cmd = 'osascript -e "set volume output volume {0}"'.format(volume)
    call = __salt__['cmd.run_all'](
        cmd,
        output_loglevel='debug',
        python_shell=False
    )
    _check_cmd(call)

    return get_output_volume()
1257193
def configure_volume(before_change=lambda: None, after_change=lambda: None):
    '''
    '''

    config = get_config()
    if not config:
        hookenv.log('Failed to read volume configuration', hookenv.CRITICAL)
        raise VolumeConfigurationError()

    if config['ephemeral']:
        if os.path.ismount(config['mountpoint']):
            before_change()
            unmount_volume(config)
            after_change()
        return 'ephemeral'
    else:
        # persistent storage
        if os.path.ismount(config['mountpoint']):
            mounts = dict(managed_mounts())
            if mounts.get(config['mountpoint']) != config['device']:
                before_change()
                unmount_volume(config)
                mount_volume(config)
                after_change()
        else:
            before_change()
            mount_volume(config)
            after_change()
        return config['mountpoint']
57462
def _change_volume(self, increase):
        
        sign = "+" if increase else "-"
        delta = "%d%%%s" % (self.volume_tick, sign)
        self._run(["amixer", "-q", "sset", "Master", delta])
1350568
def set_mute(self, enable):
        """"""
        data = '1' if enable else '0'
        params = ('<InstanceID>0</InstanceID><Channel>Master</Channel>'
                  '<DesiredMute>{}</DesiredMute>').format(data)
        self.soap_request(URL_CONTROL_DMR, URN_RENDERING_CONTROL,
                          'SetMute', params)
928376
def set_muted(self, status):
        """"""
        new_volume = self._client['config']['volume']
        new_volume['muted'] = status
        self._client['config']['volume']['muted'] = status
        yield from self._server.client_volume(self.identifier, new_volume)
        _LOGGER.info('set muted to %s on %s', status, self.friendly_name)
866797
def toggle_mute(self, controller, zone):
        

        send_msg = self.create_send_message("F0 @cc 00 7F 00 @zz @kk 05 02 02 00 00 F1 40 00 00 00 0D 00 01",
                                            controller, zone)
        self.send_data(send_msg)
        self.get_response_message()
1361872
def get_speaker_volume(self):
        """"""
        if not self.camera_extended_properties:
            return None

        speaker = self.camera_extended_properties.get('speaker')
        if not speaker:
            return None

        return speaker.get('volume')
997846
def remove_volume(self, volume_name):
        
        logger.info("removing volume '%s'", volume_name)
        try:
            self.d.remove_volume(volume_name)
        except APIError as ex:
            if ex.response.status_code == requests.codes.CONFLICT:
                logger.debug("ignoring a conflict when removing volume %s", volume_name)
            else:
                raise ex
755049
def increase_volume(percentage):
	'''
	'''

	if percentage > 100 or percentage < 0:
		raise ValueError('percentage must be an integer between 0 and 100')

	if system.get_name() == 'windows':
		# TODO: Implement volume for Windows. Looks like WinAPI is the
		# solution...
		pass

	elif system.get_name() == 'mac':
		volume_int = percentage / 10
		old_volume = get()

		new_volume = old_volume + volume_int

		if new_volume > 10:
			new_volume = 10

		set_volume(new_volume * 10)

	else:
		# Linux/Unix
		formatted = '%d%%+' % percentage
		# + or - increases/decreases in amixer

		sp.Popen(['amixer', '--quiet', 'sset', 'Master', formatted]).wait()
770845
def set_muted(self, status):
        """"""
        self._group['muted'] = status
        yield from self._server.group_mute(self.identifier, status)
        _LOGGER.info('set muted to %s on %s', status, self.friendly_name)
93562
def _no_mute_on_stop_playback(self):
        
        if self.ctrl_c_pressed:
            return
        if self.isPlaying():
            if self.actual_volume == -1:
                self._get_volume()
                while self.actual_volume == -1:
                    pass
            if self.actual_volume == 0:
                self.actual_volume = int(self.max_volume*0.25)
                self._sendCommand('volume {}\n'.format(self.actual_volume))
                if logger.isEnabledFor(logging.DEBUG):
                    logger.debug('Unmuting VLC on exit: {} (25%)'.format(self.actual_volume))
            elif self.muted:
                if self.actual_volume > 0:
                    self._sendCommand('volume {}\n'.format(self.actual_volume))
                    if logger.isEnabledFor(logging.DEBUG):
                        logger.debug('VLC volume restored on exit: {0} ({1}%)'.format(self.actual_volume, int(100 * self.actual_volume / self.max_volume)))

            self.show_volume = True
1360197
def mute(self):
        

        response = self.renderingControl.GetMute([
            ('InstanceID', 0),
            ('Channel', 'Master')
        ])
        mute_state = response['CurrentMute']
        return True if int(mute_state) else False