volume method
Set the volume for the user’s current playback device.
volumePercent
is required. The volume to set. Must be a value from 0
to
100
inclusive.
deviceId
is optional. If not provided, the user's currently active device
is the target.
retrievePlaybackState
is optional. If true
, the current playback state
will be retrieved. Defaults to true
.
Implementation
Future<PlaybackState?> volume(int volumePercent,
{String? deviceId, bool retrievePlaybackState = true}) async {
assert(volumePercent >= 0 && volumePercent <= 100,
'Volume must be between 0 and 100');
await _api._put('$_path/volume?${_buildQuery({
'volume_percent': volumePercent,
'device_id': deviceId
})}');
return retrievePlaybackState ? playbackState() : null;
}