コード例 #1
0
        public void ArtistUri_ArtistUriLeadingWhitespace_ThrowsArgumentException()
        {
            // arrange
            const string uri = " spotify:album:0TnOYISbd1XYRBk9myaseg";

            // act
            SpotifyUriHelper.ArtistUri(uri);
        }
コード例 #2
0
        public void ArtistUri_ArtistUriWhitespaceString_ThrowsArgumentException()
        {
            // arrange
            const string uri = " ";

            // act
            SpotifyUriHelper.ArtistUri(uri);
        }
コード例 #3
0
        public void ArtistUri_ArtistUriNull_ThrowsArgumentException()
        {
            // arrange
            const string uri = null;

            // act
            SpotifyUriHelper.ArtistUri(uri);
        }
コード例 #4
0
        /// <summary>
        /// BETA. Play an Artist on the user’s active device.
        /// </summary>
        /// <param name="artistId">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 PlayArtist(string artistId, string accessToken = null, string deviceId = null, long positionMs = 0)
        {
            if (string.IsNullOrEmpty(artistId))
            {
                throw new ArgumentNullException(nameof(artistId));
            }
            dynamic data = JObject.FromObject(new { context_uri = SpotifyUriHelper.ArtistUri(artistId) });

            await Play(data, accessToken, deviceId, positionMs);
        }
コード例 #5
0
        public void ArtistUri_UserCollectionArtist_ReturnsCollectionUri()
        {
            // arrange
            const string collectionUri = "spotify:user:daniellarsennz:collection:artist:65XA3lk0aG9XejO8y37jjD";

            // act
            string uri = SpotifyUriHelper.ArtistUri(collectionUri);

            // assert
            Assert.AreEqual(collectionUri, uri);
        }
コード例 #6
0
        public void ArtistUri_ValidArtistUri_ReturnsArtistUri()
        {
            // arrange
            const string uri = "spotify:artist:0TnOYISbd1XYRBk9myaseg";

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

            // assert
            Assert.AreSame(uri, result);
        }
コード例 #7
0
        /// <summary>
        /// BETA. Play an Artist from a Track offset on the user’s active device.
        /// </summary>
        /// <param name="artistId">Spotify Artust Id to play</param>
        /// <param name="offsetPosition">From where in the Artist top track list playback should start</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 PlayArtistOffset(
            string artistId,
            int offsetPosition,
            string accessToken = null,
            string deviceId    = null,
            long positionMs    = 0)
        {
            dynamic data = JObject.FromObject(new { context_uri = SpotifyUriHelper.ArtistUri(artistId) });

            if (offsetPosition > 0)
            {
                data.offset = JObject.FromObject(new { position = offsetPosition });
            }
            await Play(data, accessToken, deviceId, positionMs);
        }