From 11bbffeaef9c17c7a9750b65373ed0e95d37108a Mon Sep 17 00:00:00 2001 From: Hayri Bakici Date: Mon, 17 Apr 2023 11:49:09 +0200 Subject: [PATCH 1/2] transfer --- lib/src/endpoints/player.dart | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/src/endpoints/player.dart b/lib/src/endpoints/player.dart index c2d3e35..b73ad3e 100644 --- a/lib/src/endpoints/player.dart +++ b/lib/src/endpoints/player.dart @@ -170,12 +170,12 @@ class PlayerEndpoint extends _MeEndpointBase { } /// 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. + /// [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. + /// [retrievePlaybackState] is optional. If `true`, the current playback state + /// will be retrieved. Defaults to `true`. Future volume(int volumePercent, {String? deviceId, bool retrievePlaybackState = true}) async { assert(volumePercent >= 0 && volumePercent <= 100, @@ -185,4 +185,21 @@ class PlayerEndpoint extends _MeEndpointBase { return retrievePlaybackState ? playbackState() : null; } + + /// Transfer playback to a new device and determine if + /// it should start [play]ing. 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`. + Future transfer(String deviceId, + [bool play = true, bool retrievePlaybackState = true]) async { + assert(deviceId.isNotEmpty, 'No deviceId provided'); + var jsonBody = jsonEncode({ + 'device_id': [deviceId], + 'play': play + }); + await _api._put(_path, jsonBody); + return retrievePlaybackState ? playbackState() : null; + } } From 32f716343cb7b86203a68dd6caaa6fcb8b7c6d35 Mon Sep 17 00:00:00 2001 From: Hayri Bakici Date: Tue, 18 Apr 2023 15:07:03 +0200 Subject: [PATCH 2/2] adds transfer api --- lib/src/endpoints/player.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/endpoints/player.dart b/lib/src/endpoints/player.dart index b73ad3e..2e3abb5 100644 --- a/lib/src/endpoints/player.dart +++ b/lib/src/endpoints/player.dart @@ -188,7 +188,7 @@ class PlayerEndpoint extends _MeEndpointBase { /// Transfer playback to a new device and determine if /// it should start [play]ing. 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`. @@ -196,7 +196,7 @@ class PlayerEndpoint extends _MeEndpointBase { [bool play = true, bool retrievePlaybackState = true]) async { assert(deviceId.isNotEmpty, 'No deviceId provided'); var jsonBody = jsonEncode({ - 'device_id': [deviceId], + 'device_ids': [deviceId], 'play': play }); await _api._put(_path, jsonBody);