private IEnumerable<Album> getAlbumsByArtist(Artist artist, bool isAlbumArtist)
        {
            List<Album> returnedAlbums = new List<Album>();
            List<string> albumNames = new List<string>();
            iTunesApp iTunes = null;

            try
            {
                iTunes = new iTunesApp();

                if(isAlbumArtist)
                {
                    foreach (IITFileOrCDTrack track in iTunes.LibraryPlaylist.Tracks)
                    {
                        // If the artist doesn't match, or if we already have the album,
                        // just keep going
                        if (!string.Equals(track.AlbumArtist, artist.Name) || albumNames.Contains(track.Album))
                        {
                            continue;
                        }

                        Album album = track.GetAlbum();
                        albumNames.Add(album.Title);
                        returnedAlbums.Add(album);
                    }
                }
                else
                {
                    foreach(IITFileOrCDTrack track in iTunes.LibraryPlaylist.Search(artist.Name, ITPlaylistSearchField.ITPlaylistSearchFieldArtists))
                    {
                        if (!string.Equals(track.Artist, artist.Name) || albumNames.Contains(track.Album))
                        {
                            continue;
                        }

                        Album album = track.GetAlbum();
                        albumNames.Add(album.Title);
                        returnedAlbums.Add(album);
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtility.LogException(ex);
                throw;
            }
            finally
            {
                // Marshall.ReleaseComObject?
            }

            return returnedAlbums;
        }
 public MediaState PlayArtist(Artist artist, bool enqueue)
 {
     throw new NotImplementedException();
 }
 public IEnumerable<Album> GetAlbumsByArtist(Artist artist)
 {
     return getAlbumsByArtist(artist, false);
 }
 public IEnumerable<Track> GetTracksByArtist(Artist artist)
 {
     return getTracksByArtist(artist.Name, false);
 }
 public MediaState PlayArtist(Artist artist, bool enqueue)
 {
     MediaLibraryService service = new MediaLibraryService();
     return PlayTracks(service.GetTracksByArtist(artist), enqueue);
 }
        private static void CacheArtists(WindowsMediaPlayer mediaPlayer)
        {
            // Get the album titles
                IWMPStringCollection artistNames = mediaPlayer.mediaCollection
                    .getAttributeStringCollection(MediaAttributes.DisplayArtist, MediaType.Audio);

                for (int i = 0; i < artistNames.count; i++)
                {
                    if (!_artistCache.ContainsKey(artistNames.Item(i).ToLower()))
                    {
                        string artistName = artistNames.Item(i);
                        if (artistName != null && !string.IsNullOrEmpty(artistName))
                        {
                            Artist artist = new Artist()
                            {
                                Name = artistName
                            };

                            _artistCache.Add(artist.Name.ToLower(), artist);
                        }
                    }
                }
        }
示例#7
0
 public static Artist GetArtist(this IITFileOrCDTrack track)
 {
     Artist artist = new Artist();
     artist.Name = track.Artist;
     return artist;
 }
 public IEnumerable<Track> GetTracksByArtist(Artist artist)
 {
     throw new NotImplementedException();
 }
 public IEnumerable<Album> GetAlbumsByArtist(Artist artist)
 {
     throw new NotImplementedException();
 }