From 54b9e04e14fb5a0884744b3e22a739cc3be9df0e Mon Sep 17 00:00:00 2001 From: Hayri Bakici Date: Tue, 2 Jan 2024 21:25:39 +0100 Subject: [PATCH 1/2] fixes #191 --- lib/src/endpoints/player.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/endpoints/player.dart b/lib/src/endpoints/player.dart index df4faf8..830694d 100644 --- a/lib/src/endpoints/player.dart +++ b/lib/src/endpoints/player.dart @@ -36,6 +36,9 @@ class PlayerEndpoint extends _MeEndpointBase { Future playbackState([Market? market]) async { var jsonString = await _api ._get('$_path?' + _buildQuery({'market': market?.name})); + if (jsonString.isEmpty) { + return PlaybackState(); + } final map = json.decode(jsonString); return PlaybackState.fromJson(map); } From aae89b0403fa6a2430fa54cd3856e7d8fd9e5315 Mon Sep 17 00:00:00 2001 From: Hayri Bakici <3295340+hayribakici@users.noreply.github.com> Date: Tue, 16 Jan 2024 23:55:37 +0100 Subject: [PATCH 2/2] Adds more documentation --- lib/src/endpoints/player.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/endpoints/player.dart b/lib/src/endpoints/player.dart index 830694d..5c32eb5 100644 --- a/lib/src/endpoints/player.dart +++ b/lib/src/endpoints/player.dart @@ -25,14 +25,16 @@ class PlayerEndpoint extends _MeEndpointBase { } /// Returns the current playback state, including progress, track - /// and active device. + /// and active device. Returns an empty [PlaybackState] object when + /// no playback context has been started. @Deprecated('Use [playbackState] instead') Future player([String? market]) async { return playbackState(Market.values.asNameMap()[market]); } /// Returns the current playback state, including progress, track - /// and active device. + /// and active device. Returns an empty [PlaybackState] object when + /// no playback context has been started. Future playbackState([Market? market]) async { var jsonString = await _api ._get('$_path?' + _buildQuery({'market': market?.name}));