public void TrackUri_ValidTrackUri_ReturnsTrackUri()
        {
            // arrange
            const string uri = "spotify:track:0TnOYISbd1XYRBk9myaseg";

            // act
            string result = SpotifyUriHelper.TrackUri(uri);

            // assert
            Assert.AreSame(uri, result);
        }
Example #2
0
        /// <summary>
        /// BETA. Play a Playlist on the user’s active device.
        /// </summary>
        /// <param name="playlistId">Spotify Playlist Id to play</param>
        /// <param name="offsetTrackId">Id of the Track to start at</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 PlayPlaylistOffset(
            string playlistId,
            string offsetTrackId,
            string accessToken = null,
            string deviceId    = null,
            long positionMs    = 0)
        {
            dynamic data = JObject.FromObject(new { context_uri = SpotifyUriHelper.PlaylistUri(playlistId) });

            if (offsetTrackId != null)
            {
                data.offset = JObject.FromObject(new { uri = SpotifyUriHelper.TrackUri(offsetTrackId) });
            }
            await Play(data, accessToken, deviceId, positionMs);
        }