public void Add(Song song) { if (song == null) return; songs.Add(song); Sorting.AddSongToSortDictionaries(song, this.sortDictionaries); }
public SongPropertiesWindow(MainForm mainForm, Song song, int clickedIndex, PlaylistBase currentPlaylist, Library library) { this.mainForm = mainForm; this.song = song; this.currentIndex = clickedIndex; this.currentPlaylist = currentPlaylist; this.library = library; InitializeComponent(); }
private void AddSongsToLibrary(Library lib) { var song = new Song(@"Songs\empty10sec.mp3"); song.Rating = 3; lib.Add(song); song = new Song(@"Songs\empty10sec2.mp3"); song.Rating = 1; lib.Add(song); }
public void SongLoad() { try { Song s = new Song(@"Songs\empty10sec.mp3"); } catch { Assert.Fail(); } }
public override void UpdateSongInfo(Song song) { RemoveFromSortDictionaries(song); bool allowed = Filters.All(f => f.Allowed(song)); if (!allowed) songs.Remove(song); else { if (!songs.Contains(song)) songs.Add(song); Sorting.AddSongToSortDictionaries(song, this.sortDictionaries); } }
public void SongTag() { string titleExpected = "empty10sec - 1"; string artistExpected = "artist"; string albumExpected = "album"; string genreExpected = "noise"; int trackNumberExpected = 1; int discNumberExpected = 1; Song s = new Song(@"Songs\empty10sec.mp3"); Assert.AreEqual(s.Title, titleExpected); Assert.AreEqual(s.Artist, artistExpected); Assert.AreEqual(s.Album, albumExpected); Assert.AreEqual(s.Genre, genreExpected); Assert.AreEqual(s.TrackNumber, trackNumberExpected); Assert.AreEqual(s.DiscNumber, discNumberExpected); }
public void SongReload() { Song s = null; try { s = new Song(@"Songs\empty10sec.mp3"); } catch { Assert.Fail("Load fail"); } try { s.ReloadTags(); } catch { Assert.Fail("Reload fail"); } }
/// <summary> /// Interval in ms /// </summary> /// <param name="song"></param> /// <param name="interval"></param> private SongInfoPopup(Song song, Image albumArt, int interval) { InitializeComponent(); Screen currentScreen = Screen.PrimaryScreen; this.Left = currentScreen.WorkingArea.Right - this.Width; this.Top = currentScreen.WorkingArea.Bottom - this.Height; title_label.Text = song.Title; artist_label.Text = song.Artist; album_label.Text = song.Album; length_label.Text = song.LengthString; rating_label.Text = song.RatingString; pictureBox1.Image = albumArt; this.Show(); popupTimer = new Timer(); popupTimer.Interval = interval; popupTimer.Tick += popupTimer_Tick; popupTimer.Start(); }
private void GetNextOrPrevious(bool getNext) { //Index juggling required as GetNext() and GetPrevious() increments playing playlist index //The methods also jump to the beginning/end of a playlist if you pass the end/beginning //So this way is probably more convenient int oldIndex = currentPlaylist.CurrentIndex; currentPlaylist.CurrentIndex = this.currentIndex; if (getNext) song = currentPlaylist.GetNext(); else song = currentPlaylist.GetPrevious(); this.currentIndex = currentPlaylist.CurrentIndex; currentPlaylist.CurrentIndex = oldIndex; }
/// <summary> /// Removes one song from a dictionary /// </summary> /// <param name="dictionary"></param> /// <param name="field"></param> /// <param name="song"></param> private static void RemoveSongFromFieldDictionary(Dictionary <string, List <Song> > dictionary, string field, Song song) { if (dictionary.ContainsKey(song[field])) { dictionary[song[field]].Remove(song); if (dictionary[song[field]].Count == 0) { dictionary.Remove(song[field]); } } }
private void OnSongChanged(Song song) { if (SongChanged != null) SongChanged(this, new SongChangedEventArgs(song)); }
protected void RemoveFromSortDictionaries(Song song) { foreach (Dictionary<string, List<Song>> dictionary in this.sortDictionaries) foreach (List<Song> list in dictionary.Values) if (list.Contains(song)) list.Remove(song); }
private void PlaySong(Song song, PlaylistBase inPlaylist) { searchBarTimer.Stop(); musicPlayer.Stop(); musicPlayer.Volume = 0; // Check Last.fm scrobbling requirements if (currentSongTimePlayed.Ticks > 0.8 * musicPlayer.Length.Ticks || currentSongTimePlayed.TotalMinutes > 4) { currentSongTimePlayed = TimeSpan.Zero; currentlyPlaying.LastPlayed = DateTime.Now; currentlyPlaying.PlayCount++; if (settings.ScrobblingEnabled) if (currentlyPlaying.Length.TotalSeconds > 30) lfmHandler.ScrobbleSong(currentlyPlaying); RefreshSongGridView(); } if (!ReloadSong(song)) return; ResetSearchBarTimer(); searchBarTimer.Stop(); try { musicPlayer.Open(song.Path); } catch (Exception ex) { MessageBox.Show("Play music exception: " + ex.ToString()); } this.currentlyPlaying = song; this.playingPlaylist = inPlaylist; UpdateTrayIconText(); UpdateSongImage(); UpdateSongLengthLabel(); UpdateSongInfoLabel(); if (inPlaylist == shuffleQueue) { shuffleQueue.Populate(); if (showingPlaylist == shuffleQueue) UpdateShowingPlaylist(); } // Saves changed from tag editing when song is not playing any more if (songToSave != null && songToSave.Path != currentlyPlaying.Path) { songToSave.Save(); songToSave = null; } // Show song popup according to settings if (settings.PopupOnSongChange) ShowCurrentSongPopup(); inPlaylist.Save(); }
private void UpdateSong(Song song) { foreach (PlaylistBase pl in playlists) pl.UpdateSongInfo(song); }
private void RateSong(Song s, int rating) { s.Rating = rating; library.UpdateSongInfo(currentlyPlaying); UpdateSong(s); RefreshSongGridView(); if (showingPlaylist.GetType() == typeof(FilterPlaylist)) UpdateShowingPlaylist(); }
public SavePlayingSongEventArgs(Song savingSong) : base() { SavingSong = savingSong; }
/// <summary> /// Time in ms /// </summary> /// <param name="s"></param> /// <param name="time"></param> public static void ShowPopup(Song s, Image albumArt, int time) { SongInfoPopup popup = new SongInfoPopup(s, albumArt, time); }
private static void AddSongsToLibrary(Library lib) { var song = new Song(@"Songs\empty10sec.mp3"); song.Rating = 3; song.DateAdded = DateTime.Now.AddDays(-1); lib.Add(song); song = new Song(@"Songs\empty10sec2.mp3"); song.DateAdded = DateTime.Now.AddDays(-8); lib.Add(song); song = new Song(@"Songs\empty10sec3.mp3"); song.DateAdded = DateTime.Now.AddMonths(-3); song.Rating = 5; lib.Add(song); }
public SongChangedEventArgs(Song changedSong) : base() { ChangedSong = changedSong; }
public override void Add(string path) { Song newSong = null; try { newSong = new Song(path); } catch { MessageBox.Show("File read error"); } if (newSong != null) Add(newSong); }
private void popup_SavePlayingSong(object sender, SavePlayingSongEventArgs e) { songToSave = e.SavingSong; }
public void Add(Song song) { if (song != null) if (!pathDictionary.ContainsKey(song.Path)) { songs.Add(song); this.pathDictionary.Add(song.Path, song); Sorting.AddSongToSortDictionaries(song, sortDictionaries); NotifyChanged(); } }
/// <summary> /// True if reaload was successful /// </summary> /// <param name="song"></param> /// <returns></returns> private bool ReloadSong(Song song) { try { this.currentAlbumArt = song.ReloadAndGetImage(); UpdateSong(song); } catch (SongReadException ex) { OnSongReadException(ex, song); return false; } return true; }
public void Remove(Song song) { Remove(song.Path); }
private void OnSongReadException(SongReadException ex, Song song) { MessageBox.Show("Song at " + song.Path + " could not be read and will be removed from the library."); library.Remove(song); }
public override void UpdateSongInfo(Song song) { //Remove from all dictionaries foreach (Dictionary<string, List<Song>> dictionary in this.sortDictionaries) foreach (List<Song> list in dictionary.Values) if (list.Contains(song)) list.Remove(song); Sorting.AddSongToSortDictionaries(song, this.sortDictionaries); }
public void ScrobbleSong(Song song) { scrobbleQueue.Add(new Scrobble(song.Artist, song.Album, song.Title, song.LastPlayed)); StartWorker(); }
private void addFilesWorker_DoWork(object sender, DoWorkEventArgs e) { var worker = sender as BackgroundWorker; List<string> musicFiles = e.Argument as List<string>; int count = 0; foreach (string fileName in musicFiles) { if (!Exists(fileName)) { Song newSong; try { newSong = new Song(fileName); } catch { newSong = null; this.invalidSongPaths.Add(fileName); } if (newSong != null) { this.newSongs.Add(newSong); if (count % 50 == 0) worker.ReportProgress((int)(100 * count / musicFiles.Count)); } } count++; } worker.ReportProgress(100); }
private void OnSavePlayingSong(Song song) { if (SavePlayingSong != null) SavePlayingSong(this, new SavePlayingSongEventArgs(song)); }
public abstract void UpdateSongInfo(Song song);
private void SaveSong(Song song) { if (this.saveProperties["Title"]) song.Title = this.title_box.Text; if (this.saveProperties["Artist"]) song.Artist = this.artist_box.Text; if (this.saveProperties["Album"]) song.Album = this.album_box.Text; if (this.saveProperties["Track Number"]) song.TrackNumber = Convert.ToInt32(this.tracknr_box.Text); if (this.saveProperties["Disc Number"]) song.DiscNumber = Convert.ToInt32(this.discnr_box.Text); if (this.saveProperties["Genre"]) song.Genre = this.genre_box.Text; if (this.saveProperties["Rating"]) song.Rating = (int)this.rating_numupdownstring.Value; if (song != this.mainForm.CurrentlyPlaying) song.Save(); else OnSavePlayingSong(song); OnSongChanged(song); this.library.UpdateSongInfo(song); }
/// <summary> /// Adds a single song to one of the dictionaries. /// </summary> /// <param name="dictionary"></param> /// <param name="field"></param> /// <param name="song"></param> private static void AddSongToFieldDictionary(Dictionary <string, List <Song> > dictionary, string field, Song song) { if (song[field] != null && dictionary.ContainsKey(song[field])) { dictionary[song[field]].Add(song); } else { var newEntry = new List <Song>(); newEntry.Add(song); if (song[field] != null) { dictionary.Add(song[field], newEntry); } } }