transfer method

Future<PlaybackState?> transfer(
  1. String deviceId, [
  2. bool play = true,
  3. bool retrievePlaybackState = true
])

Transfer playback to a new device and determine if it should start playing. Default is true.

The AuthorizationScope.connect.modifyPlaybackState needs to be set. retrievePlaybackState is optional. If true, the current playback state will be retrieved. Defaults to true.

Implementation

Future<PlaybackState?> transfer(String deviceId,
    [bool play = true, bool retrievePlaybackState = true]) async {
  assert(deviceId.isNotEmpty, 'No deviceId provided');
  var jsonBody = jsonEncode({
    'device_ids': [deviceId],
    'play': play
  });
  await _api._put(_path, jsonBody);
  return retrievePlaybackState ? playbackState() : null;
}