public SongPropertiesWindow(MainForm mainForm, Song song, int clickedIndex, IPlaylist currentPlaylist, Library library)
        {
            this.mainForm = mainForm;
            this.song = song;
            this.currentIndex = clickedIndex;
            this.currentPlaylist = currentPlaylist;
            this.library = library;

            InitializeComponent();
        }
Exemple #2
0
        /// <summary>
        /// Interval in ms
        /// </summary>
        /// <param name="song"></param>
        /// <param name="interval"></param>
        private SongInfoPopup(Song song, 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 = Song.GetImage(song);

            this.Show();

            popupTimer = new Timer();
            popupTimer.Interval = interval;
            popupTimer.Tick += popupTimer_Tick;
            popupTimer.Start();
        }
Exemple #3
0
 public void Remove(Song song)
 {
     Remove(song.Path);
 }
Exemple #4
0
        public 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);
        }
Exemple #5
0
 private void RateSong(Song s, int rating)
 {
     s.Rating = rating;
     library.UpdateSongInfo(currentlyPlaying);
     UpdateSongForRatingFilterPlaylist(s);
     UpdateFilterPlaylistSongPaths();
     RefreshSongGridView();
     playingPlaylist.Save();
     if (showingPlaylist.GetType() == typeof(RatingFilterPlaylist))
         UpdateShowingPlaylist(true);
 }
Exemple #6
0
 public void Add(Song song)
 {
     if (song != null)
         if (!pathDictionary.ContainsKey(song.Path))
         {
             outputSongs.Add(song);
             this.pathDictionary.Add(song.Path, song);
             Sorting.AddSongToSortDictionaries(song, sortDictionaries);
             OnLibraryChanged(new LibraryChangedEventArgs());
         }
 }
        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;
        }
Exemple #8
0
 /// <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
     {
         List<Song> newEntry = new List<Song>();
         newEntry.Add(song);
         if (song[field] != null)
             dictionary.Add(song[field], newEntry);
     }
 }
Exemple #9
0
 /// <summary>
 /// Time in ms
 /// </summary>
 /// <param name="s"></param>
 /// <param name="time"></param>
 public static void ShowPopup(Song s, int time)
 {
     SongInfoPopup popup = new SongInfoPopup(s, time);
 }
Exemple #10
0
 /// <summary>
 /// Adds a single song to the existing sortdictionaries
 /// </summary>
 /// <param name="song"></param>
 /// <param name="sortDictionaries"></param>
 public static void AddSongToSortDictionaries(Song song, List<Dictionary<string,
     List<Song>>> sortDictionaries)
 {
     for (int i = 0; i < Sorting.SortColumns.Length; i++)
         AddSongToFieldDictionary(sortDictionaries[i], Sorting.SortColumns[i], song);
 }
Exemple #11
0
 public void Insert(int index, Song song)
 {
     if (song != null)
         this.Insert(index, song.Path);
 }
Exemple #12
0
 /// <summary>
 /// True if reaload was successful
 /// </summary>
 /// <param name="song"></param>
 /// <returns></returns>
 private bool ReloadSong(Song song)
 {
     try
     {
         song.Reload();
     }
     catch (SongReloadException ex)
     {
         OnSongReloadException(ex, song);
         return false;
     }
     return true;
 }
Exemple #13
0
 public void Add(Song song)
 {
     if (song != null)
     {
         songPaths.Add(song.Path);
         this.outputSongs.Add(libraryDictionary[song.Path]);
         Sorting.AddSongToSortDictionaries(song, this.sortDictionaries);
     }
 }
        private void SaveSong(Song song)
        {
            song.Rating = (int)this.rating_numupdownstring.Value;

            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.SaveTags();
            else
                OnSavePlayingSong(song);

            this.library.UpdateSongInfo(song);
        }
Exemple #15
0
 /// <summary>
 /// Rem
 /// </summary>
 /// <param name="song"></param>
 /// <param name="sortDictionaries"></param>
 public static void RemoveSongFromSortDictionaries(Song song,
     List<Dictionary<string, List<Song>>> sortDictionaries)
 {
     for (int i = 0; i < Sorting.SortColumns.Length; i++)
         RemoveSongFromFieldDictionary(sortDictionaries[i], Sorting.SortColumns[i], song);
 }
Exemple #16
0
        void addFilesWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            string path = e.Argument as string;

            string[] mp3Files = Directory.GetFiles(path, "*" + EXTENSION, SearchOption.AllDirectories);
            int count = 0;
            foreach (string fileName in mp3Files)
            {
                if (!Exists(fileName))
                {
                    Song newSong = new Song(fileName);
                    this.newSongs.Add(newSong);
                    if (count % 50 == 0)
                        worker.ReportProgress((int)(100 * count / mp3Files.Length));
                }
                count++;
            }

            worker.ReportProgress(100);
        }
 public SavePlayingSongEventArgs(Song savingSong)
     : base()
 {
     this.savingSong = savingSong;
 }
Exemple #18
0
 private void UpdateSongForRatingFilterPlaylist(Song song)
 {
     foreach (IPlaylist pl in playlists)
         pl.UpdateSongInfo(song);
 }
Exemple #19
0
 /// <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 OnSavePlayingSong(Song song)
 {
     if (SavePlayingSong != null)
         SavePlayingSong(this, new SavePlayingSongEventArgs(song));
 }
Exemple #21
0
 private void OnSongReloadException(SongReloadException ex, Song song)
 {
     MessageBox.Show(ex.ToString() + "\nSong will be removed from the library.");
     library.Remove(song);
 }
Exemple #22
0
        private void PlaySong(Song song, IPlaylist inPlaylist)
        {
            if (currentSongTimePlayed.Ticks > 0.95 * musicPlayer.Length.Ticks)
            {
                this.currentSongTimePlayed = TimeSpan.Zero;
                this.currentlyPlaying.LastPlayed = DateTime.Now;
                this.currentlyPlaying.PlayCount++;

                //SCROBBLE HERE IF ENABLED

                RefreshSongGridView();
            }

            if (ReloadSong(song))
            {
                ResetSearchBarTimer();
                searchBarTimer.Stop();

                try
                {
                    this.musicPlayer.Open(song.Path, defaultAudioDevice);
                    PlayMusic();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Play music exception: " + ex.ToString());
                }

                this.currentlyPlaying = song;
                this.playingPlaylist = inPlaylist;

                UpdateTrayIconText();
                UpdateSongImage();
                UpdateSongLengthLabel();
                UpdateSongInfoLabel();

                if (inPlaylist == shuffleQueue)
                    PopulateShuffleQueue();

                //Saves changed from tag editing when song is not playing any more
                if (songToSave != null)
                    if (songToSave.Path != currentlyPlaying.Path)
                    {
                        songToSave.SaveTags();
                        songToSave = null;
                    }
            }
        }
Exemple #23
0
 private void popup_SavePlayingSong(object sender, SavePlayingSongEventArgs e)
 {
     songToSave = e.savingSong;
 }
Exemple #24
0
 public static System.Drawing.Image GetImage(Song song)
 {
     TagLib.File tagFile = TagLib.File.Create(song.Path);
     if (tagFile.Tag.Pictures.Length > 0)
     {
         MemoryStream ms = new MemoryStream(tagFile.Tag.Pictures[0].Data.Data);
         return System.Drawing.Image.FromStream(ms);
     }
     return null;
 }
        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);

            if ((song.Rating == allowedRating) || (IncludeHigher && (song.Rating > allowedRating)))
                Sorting.AddSongToSortDictionaries(song, this.sortDictionaries);
        }