Exemplo n.º 1
0
        void api_OnGetPlaylistsComplete(GoogleMusicPlaylists pls)
        {
            this.pls = pls;

            this.Invoke(new MethodInvoker(delegate
            {
                foreach (GoogleMusicPlaylist pl in pls.UserPlaylists)
                {
                    lbPlaylists.Items.Add(pl.Title);
                }

                foreach (GoogleMusicPlaylist pl in pls.InstantMixes)
                {
                    lbPlaylists.Items.Add(pl.Title);
                }
            }));
        }
Exemplo n.º 2
0
        private void PlaylistRecv(HttpWebRequest request, HttpWebResponse response, String jsonData, Exception error)
        {
            if (error != null)
            {
                ThrowError(error);
            }

            GoogleMusicPlaylists playlists = null;

            try
            {
                playlists = JsonConvert.DeserializeObject <GoogleMusicPlaylists>(jsonData);
            }
            catch (Exception e)
            {
                ThrowError(error);
            }

            if (OnGetPlaylistsComplete != null)
            {
                OnGetPlaylistsComplete(playlists);
            }
        }
        private void PopulatePlaylistList(GoogleMusicPlaylists playlists)
        {
            int numPlaylists = playlists.InstantMixes.Count + playlists.UserPlaylists.Count + 1;
            SortedList<String, GoogleMusicPlaylist> result = new SortedList<String, GoogleMusicPlaylist>(numPlaylists);

            result.Add("All Songs", null);

            foreach (GoogleMusicPlaylist userPl in playlists.UserPlaylists)
            {
                String name = "Playlist: " + userPl.Title;
                if (result.ContainsKey(name))
                {
                    int counter = 1;
                    while (result.ContainsKey(name + " (" + counter.ToString() + ")"))
                        counter++;
                    name += " (" + counter.ToString() + ")";
                }
                result.Add(name, userPl);
            }

            foreach (GoogleMusicPlaylist mix in playlists.InstantMixes)
            {
                String name = "Instant Mix: " + mix.Title;
                if (result.ContainsKey(name))
                {
                    int counter = 1;
                    while (result.ContainsKey(name + " (" + counter.ToString() + ")"))
                        counter++;
                    name += " (" + counter.ToString() + ")";
                }
                result.Add(name, mix);
            }

            this.PlaylistMap = result;
        }
 private void GotAllPlaylists(GoogleMusicPlaylists playlists)
 {
     this.allPlaylists = playlists;
     threadResult = ThreadResult.GOTALLPL;
     threadHandler.Set();
 }