Ejemplo n.º 1
0
        public async Task TestSearchAndLookup()
        {
            // Search for "Daft Punk"
            ContentResponse searchResults = await Client.SearchAsync(Namespace.music, "Daft Punk", country : "US").Log();

            Assert.IsNotNull(searchResults, "The search response should not be null");
            AssertPaginatedListIsValid(searchResults.Artists, 1, 1);
            AssertPaginatedListIsValid(searchResults.Albums, 10, 20);
            AssertPaginatedListIsValid(searchResults.Tracks, 25, 100);
            Assert.IsNotNull(searchResults.Tracks.ContinuationToken, "Search results should contain continuation for tracks");

            // Get the 2nd page of track results
            ContentResponse continuedSearchResults =
                await Client.SearchContinuationAsync(Namespace.music, searchResults.Tracks.ContinuationToken).Log();

            Assert.IsNotNull(continuedSearchResults, "The continued search response should not be null");
            Assert.IsNull(continuedSearchResults.Artists, "The continued search response should not contain artists");
            Assert.IsNull(continuedSearchResults.Albums, "The continued search response should not contain albums");
            AssertPaginatedListIsValid(continuedSearchResults.Tracks, 25, 100);

            // List tracks in the first album
            Album           firstAlbum        = searchResults.Albums.Items.First();
            ContentResponse albumTrackResults = await Client.LookupAsync(firstAlbum.Id, extras : ExtraDetails.Tracks, country : "US").Log();

            AssertPaginatedListIsValid(albumTrackResults.Albums, 1);
            Album firstAlbumLookup = albumTrackResults.Albums.Items.First();

            Assert.AreEqual(firstAlbum.Id, firstAlbumLookup.Id, "Album ids should be the same");
            Assert.IsNotNull(firstAlbumLookup.Tracks, "Album should have tracks");
            Assert.IsNotNull(firstAlbumLookup.Tracks.Items, "Album should have tracks");
        }
Ejemplo n.º 2
0
        public async Task TestLookupPublicPlaylist()
        {
            // Tip: You get your own playlistId by opening your playlist on http://music.xbox.com
            //      If the page is http://music.xbox.com/playlist/great-music/66cd8e9d-802a-00fe-364d-3ead4f82facf
            //      the id is music.playlist.66cd8e9d-802a-00fe-364d-3ead4f82facf .
            const string playlistId = "music.playlist.0016e20b-80c0-00fe-fac0-1a47365516d1";

            // Get playlist contents as viewed from the US
            ContentResponse playlistUsResponse =
                await Client.LookupAsync(playlistId, ContentSource.Collection, country : "US").Log();

            foreach (var track in playlistUsResponse.Playlists.Items.First().Tracks.Items)
            {
                Console.WriteLine("  Track {0} can be {1} in the US", track.Id, String.Join(" and ", track.Rights));
            }

            // Get playlist contents as viewed from Brasil
            // Note that rights (such as Stream, FreeStream and Purchase) and collection item ids can be country specific
            ContentResponse playlistBrResponse =
                await Client.LookupAsync(playlistId, ContentSource.Collection, country : "BR").Log();

            foreach (var track in playlistBrResponse.Playlists.Items.First().Tracks.Items)
            {
                Console.WriteLine("  Track {0} can be {1} in Brasil", track.Id, String.Join(" and ", track.Rights));
            }
        }
Ejemplo n.º 3
0
        public async Task TestArtistImage()
        {
            const string katyPerryId = "music.97e60200-0200-11db-89ca-0019b92a3933";

            // Lookup Katy Perry's information
            ContentResponse lookupResponse = await Client.LookupAsync(katyPerryId, country : "US").Log();

            Artist artist = lookupResponse.Artists.Items.First();

            // Get a 1920x1080 image URL
            string squareImageUrl = artist.GetImageUrl(1920, 1080);

            Console.WriteLine("1920x1080 image URL: {0}", squareImageUrl);

            // Get the default image URL
            string defaultImageUrl = artist.ImageUrl;

            Console.WriteLine("Default image URL: {0}", defaultImageUrl);
        }
Ejemplo n.º 4
0
        public async Task TestLinks()
        {
            const string katyPerryId = "music.97e60200-0200-11db-89ca-0019b92a3933";

            // Lookup Katy Perry's information, including latest album releases
            ContentResponse lookupResponse = await Client.LookupAsync(katyPerryId, extras : ExtraDetails.Albums, country : "US").Log();

            Artist artist = lookupResponse.Artists.Items.First();

            // Create a link to Katy Perry's artist page in an Xbox Music client
            string artistPageDeepLink = artist.Link;

            Console.WriteLine("Artist page deep link: {0}", artistPageDeepLink);
            Assert.IsNotNull(artistPageDeepLink, "The artist page deep link should not be null");

            // Create a link which starts playback of Katy Perry's latest album in the US (exclude singles and EPs)
            Album  album             = artist.Albums.Items.First(a => a.AlbumType == "Album");
            string albumPlayDeepLink = album.GetLink(ContentExtensions.LinkAction.Play);

            Console.WriteLine("Album play deep link: {0}", albumPlayDeepLink);
            Assert.IsNotNull(albumPlayDeepLink, "The album play deep link should not be null");
        }