Skip to content

Commit df53f75

Browse files
author
Jonas Dellinger
committed
Fixed ResumePlayback and added overload for uri offset, closes JohnnyCrazy#249
1 parent 6763d3c commit df53f75

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

‎SpotifyAPI/Web/SpotifyWebAPI.cs‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,29 @@ public ErrorResponse ResumePlayback(string deviceId = "", string contextUri = ""
19341934
if(uris != null)
19351935
ob.Add("uris", new JArray(uris));
19361936
if(offset != null)
1937-
ob.Add("offset", offset);
1937+
ob.Add("offset", new JObject { { "position", offset } });
1938+
return UploadData<ErrorResponse>(_builder.ResumePlayback(deviceId), ob.ToString(Formatting.None), "PUT");
1939+
}
1940+
1941+
/// <summary>
1942+
/// Start a new context or resume current playback on the user’s active device.
1943+
/// </summary>
1944+
/// <param name="deviceId">The id of the device this command is targeting. If not supplied, the user's currently active device is the target.</param>
1945+
/// <param name="contextUri">Spotify URI of the context to play.</param>
1946+
/// <param name="uris">A JSON array of the Spotify track URIs to play.</param>
1947+
/// <param name="offset">Indicates from where in the context playback should start.
1948+
/// Only available when context_uri corresponds to an album or playlist object, or when the uris parameter is used.</param>
1949+
/// <returns></returns>
1950+
public ErrorResponse ResumePlayback(string deviceId = "", string contextUri = "", List<string> uris = null,
1951+
string offset = "")
1952+
{
1953+
JObject ob = new JObject();
1954+
if (!string.IsNullOrEmpty(contextUri))
1955+
ob.Add("context_uri", contextUri);
1956+
if (uris != null)
1957+
ob.Add("uris", new JArray(uris));
1958+
if (!string.IsNullOrEmpty(offset))
1959+
ob.Add("offset", new JObject {{"uri", offset}});
19381960
return UploadData<ErrorResponse>(_builder.ResumePlayback(deviceId), ob.ToString(Formatting.None), "PUT");
19391961
}
19401962

0 commit comments

Comments
 (0)