/// <summary> /// BETA. Play an Album on the user’s active device. /// </summary> /// <param name="albumId">Spotify Album Id to play</param> /// <param name="accessToken">Optional. A valid access token from the Spotify Accounts service. /// The access token must have been issued on behalf of a user. The access token must have the /// `user-modify-playback-state` scope authorized in order to control playback. <seealso cref="UserAccountsService"/> /// </param> /// <param name="deviceId">Optional. The id of the device this command is targeting. If not supplied, the user’s /// currently active device is the target.</param> /// <param name="positionMs">Optional. Indicates from what position to start playback. Must be a positive number. /// Passing in a position that is greater than the length of the track will cause the player to start playing the /// next song.</param> /// <remarks> /// https://developer.spotify.com/documentation/web-api/reference/player/start-a-users-playback/ /// </remarks> public async Task PlayAlbum(string albumId, string accessToken = null, string deviceId = null, long positionMs = 0) { if (string.IsNullOrEmpty(albumId)) { throw new ArgumentNullException(nameof(albumId)); } dynamic data = JObject.FromObject(new { context_uri = SpotifyUriHelper.AlbumUri(albumId) }); await Play(data, accessToken, deviceId, positionMs); }
public void AlbumUri_ValidAlbumUri_ReturnsAlbumUri() { // arrange const string uri = "spotify:album:0TnOYISbd1XYRBk9myaseg"; // act string result = SpotifyUriHelper.AlbumUri(uri); // assert Assert.AreSame(uri, result); }
/// <summary> /// BETA. Play an Album from a Track offset on the user’s active device. /// </summary> /// <param name="albumId">Spotify Album Id to play</param> /// <param name="offsetPosition">From where in the Album playback should start, i.e. Track number</param> /// <param name="accessToken">Optional. A valid access token from the Spotify Accounts service. /// The access token must have been issued on behalf of a user. The access token must have the /// `user-modify-playback-state` scope authorized in order to control playback. <seealso cref="UserAccountsService"/> /// </param> /// <param name="deviceId">Optional. The id of the device this command is targeting. If not supplied, the user’s /// currently active device is the target.</param> /// <param name="positionMs">Optional. Indicates from what position to start playback. Must be a positive number. /// Passing in a position that is greater than the length of the track will cause the player to start playing the /// next song.</param> /// <remarks> /// https://developer.spotify.com/documentation/web-api/reference/player/start-a-users-playback/ /// </remarks> public async Task PlayAlbumOffset( string albumId, int offsetPosition, string accessToken = null, string deviceId = null, long positionMs = 0) { dynamic data = JObject.FromObject(new { context_uri = SpotifyUriHelper.AlbumUri(albumId) }); if (offsetPosition > 0) { data.offset = JObject.FromObject(new { position = offsetPosition }); } await Play(data, accessToken, deviceId, positionMs); }