示例#1
0
        public async Task TestStream()
        {
            // Check that the user has a Groove Music Pass subscription
            UserProfileResponse userProfileResponse = await UserAuthenticatedClient.GetUserProfileAsync(MediaNamespace.music).Log();

            // Beware: HasSubscription is bool?. You want != true instead of == false
            if (userProfileResponse.HasSubscription != true)
            {
                Assert.Inconclusive("The user doesn't have a Groove Music Pass subscription. Cannot stream from catalog.");
            }

            // Get popular tracks in the user's country
            ContentResponse browseResults = await UserAuthenticatedClient.BrowseAsync(
                MediaNamespace.music,
                ContentSource.Catalog,
                ItemType.Tracks).Log();

            Assert.IsNotNull(browseResults, "The browse response should not be null");
            AssertPaginatedListIsValid(browseResults.Tracks, 25, 100);

            // Stream the first streamable track
            Track          track          = browseResults.Tracks.Items.First(t => t.Rights.Contains("Stream"));
            StreamResponse streamResponse = await UserAuthenticatedClient.StreamAsync(track.Id, ClientInstanceId).Log();

            Assert.IsNotNull(streamResponse, "The stream URL response should not be null");
            Assert.IsNotNull(streamResponse.Url, "The stream URL should not be null");
            Assert.IsNotNull(streamResponse.ContentType, "The stream content type should not be null");
            Assert.IsNotNull(streamResponse.ExpiresOn, "The stream expiry date should not be null");
        }
        public async Task BrowseUserPlaylistsForYou()
        {
            // Get all the user's playlists for you
            ContentResponse browseResults = await UserAuthenticatedClient.BrowseAsync(
                MediaNamespace.music,
                ContentSource.Collection,
                ItemType.PlaylistsForYou).Log();

            Assert.IsNotNull(browseResults, "The browse response should not be null");
            AssertPaginatedListIsValid(browseResults.Playlists, 1);
        }