public Playlist GetPlaylistById(int sourceId, int playlistId)
        {
            if (!IsActive)
            {
                return(null);
            }

            IITPlaylist playlist;

            try
            {
                playlist = _app.GetITObjectByID(sourceId, playlistId, 0, 0) as IITPlaylist;
            }
            catch (Exception e)
            {
                Console.WriteLine($"Could not find playlist with source id {sourceId} and playlist id {playlistId}.");
                Console.WriteLine(e);
                return(null);
            }
            if (playlist != null)
            {
                return(new Playlist(playlist));
            }
            return(null);
        }
Exemplo n.º 2
0
        public void LoadPlaylist(Playlist playlist)
        {
            IITObject   playlistObject = _iTunesSucks.GetITObjectByID(playlist.iTunesSourceId, playlist.iTunesPlaylistId, 0, 0);
            IITPlaylist iTunesPlaylist = (IITPlaylist)playlistObject;

            if (playlistObject != null)
            {
                playlist.Name = iTunesPlaylist.Name;
                foreach (IITTrack iTunesTrack in iTunesPlaylist.Tracks)
                {
                    Song track = new Song()
                    {
                        Name   = iTunesTrack.Name,
                        Artist = iTunesTrack.Artist,
                    };

                    playlist.Songs.Add(track);
                }
            }
        }