Fixed ResumePlayback and added overload for uri offset, closes #249

This commit is contained in:
Jonas Dellinger 2018-07-18 22:13:01 +02:00
parent 6763d3cccc
commit df53f75368

View File

@ -1934,7 +1934,29 @@ namespace SpotifyAPI.Web
if(uris != null)
ob.Add("uris", new JArray(uris));
if(offset != null)
ob.Add("offset", offset);
ob.Add("offset", new JObject { { "position", offset } });
return UploadData<ErrorResponse>(_builder.ResumePlayback(deviceId), ob.ToString(Formatting.None), "PUT");
}
/// <summary>
/// Start a new context or resume current playback on the users active device.
/// </summary>
/// <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>
/// <param name="contextUri">Spotify URI of the context to play.</param>
/// <param name="uris">A JSON array of the Spotify track URIs to play.</param>
/// <param name="offset">Indicates from where in the context playback should start.
/// Only available when context_uri corresponds to an album or playlist object, or when the uris parameter is used.</param>
/// <returns></returns>
public ErrorResponse ResumePlayback(string deviceId = "", string contextUri = "", List<string> uris = null,
string offset = "")
{
JObject ob = new JObject();
if (!string.IsNullOrEmpty(contextUri))
ob.Add("context_uri", contextUri);
if (uris != null)
ob.Add("uris", new JArray(uris));
if (!string.IsNullOrEmpty(offset))
ob.Add("offset", new JObject {{"uri", offset}});
return UploadData<ErrorResponse>(_builder.ResumePlayback(deviceId), ob.ToString(Formatting.None), "PUT");
}