private void PopulateSongInfo(IEnumerable <MPDSongResponseBlock> response) { foreach (MPDSongResponseBlock item in response) { Playable playable = item.ToPlayable(m_DataModel); if (playable != null && playable is SongMetadata) { SongMetadata song = playable as SongMetadata; if (song.IsSpotify) { if (!m_SpotifySongCollection.ContainsKey(song.Path)) { m_SpotifySongCollection.Add(song.Path, song); } } else if (song.IsLocal) { if (!m_LocalSongCollection.ContainsKey(song.Path)) { m_LocalSongCollection.Add(song.Path, song); } } } } }
public void OnSelectedItemsChanged(IEnumerable <PlaylistItem> selection) { SelectedItems.Clear(); int localSongs = 0; int spotifySongs = 0; int streams = 0; foreach (PlaylistItem item in selection) { SelectedItems.Add(item); if (item.Content is SongMetadata) { SongMetadata song = item.Content as SongMetadata; if (song.IsLocal) { localSongs += 1; } else if (song.IsSpotify) { spotifySongs += 1; } } else if (item.Content is StreamMetadata) { streams += 1; } } NumberOfSelectedLocalSongs = localSongs; NumberOfSelectedSpotifySongs = spotifySongs; NumberOfSelectedStreams = streams; }
public AlbumMetadata AlbumOfSong(SongMetadata song) { AlbumMetadata album = null; if (m_AlbumBySong.TryGetValue(song, out album)) { return(album); } else { return(null); } }
public int CompareTo(object o) { if (o is SongMetadata) { SongMetadata rhs = (SongMetadata)o; return(StringComparer.Ordinal.Compare(Path, rhs.Path)); } else if (o is StreamMetadata) { return(-1); } else { throw new Exception("SongMetadata: attempt to compare to an incompatible object"); } }
public void ShowSongsInGenreList(IEnumerable <SongMetadata> selectedSongs) { foreach (MusicCollectionItem genreItem in Genres) { genreItem.IsSelected = false; foreach (SongMetadata selectedSong in selectedSongs) { if (genreItem.Content as string == selectedSong.Genre) { genreItem.IsSelected = true; } } } OnSelectedGenresChanged(); foreach (MusicCollectionItem albumItem in AlbumsOfSelectedGenres) { albumItem.IsSelected = false; AlbumMetadata album = albumItem.Content as AlbumMetadata; foreach (SongMetadata selectedSong in selectedSongs) { if (album.Artist == selectedSong.Artist && album.Title == selectedSong.Album) { albumItem.IsSelected = true; } } } OnSelectedAlbumsOfSelectedGenresChanged(); foreach (MusicCollectionItem songItem in SongsOnSelectedAlbumsOfSelectedGenres) { songItem.IsSelected = false; SongMetadata songInView = songItem.Content as SongMetadata; foreach (SongMetadata selectedSong in selectedSongs) { if (songInView.Path == selectedSong.Path) { songItem.IsSelected = true; } } } }
private string CurrentSongToString() { SongMetadata song = m_CurrentPlayable as SongMetadata; StringBuilder result = new StringBuilder(); result.Append(song.Artist); result.Append(": "); result.Append(song.Title); result.Append(" ("); result.Append(song.Album); if (song.Year != null) { result.Append(", "); result.Append(song.Year); } result.Append(")"); return(result.ToString()); }
public Playable ToPlayable(DataModel dataModel) { if (File == null) { return(null); } else if (File.ToLowerInvariant().StartsWith("http:")) { StreamMetadata result = new StreamMetadata(File, Name); result.Name = Name; result.Title = Title; return(result); } else if (File.StartsWith("local:track:") || File.StartsWith("spotify:track:")) { SongMetadata result = new SongMetadata(); result.Path = File; result.Title = Title; result.Genre = Genre == null ? "No Genre" : Genre; result.Album = Album == null ? "Unknown Album" : Album; result.Length = Time; result.Track = Track; result.Date = result.IsLocal ? dataModel.CustomDateNormalizer.Normalize(Date) : dataModel.YearNormalizer.Normalize(Date); if (Settings.Default.UseAlbumArtist && AlbumArtist != null) { result.Artist = AlbumArtist; } else { result.Artist = Artist == null ? "Unknown Artist" : Artist; } return(result); } else if (File.StartsWith("spotify:")) { LinkMetadata result = new LinkMetadata(); result.Path = File; result.Title = Title; return(result); } else { // Ugly copy-pasted code SongMetadata result = new SongMetadata(); result.Path = File; result.Title = Title; result.Genre = Genre == null ? "No Genre" : Genre; result.Album = Album == null ? "Unknown Album" : Album; result.Length = Time; result.Track = Track; result.Date = dataModel.YearNormalizer.Normalize(Date); if (Settings.Default.UseAlbumArtist && AlbumArtist != null) { result.Artist = AlbumArtist; } else { result.Artist = Artist == null ? "Unknown Artist" : Artist; } return(result); } }
public SongMetadataTreeViewNode(string filename, SongMetadata song, TreeViewNode parent, TreeViewController controller) : base(parent, controller) { m_Filename = filename; m_ParentIsDirectory = Parent == null || Parent is DirectoryTreeViewNode; Song = song; }