Exemple #1
0
        public static Song GenerateSong(string file)
        {
            var tagFile = TagLib.File.Create(file);
                string tempTitle;
                string tempArtist;
                string tempAlbum;
                string tempGenre;
                string tempYear;

                tempTitle = (tagFile.Tag.Title != null) ? tagFile.Tag.Title : Path.GetFileName(file);
                tempArtist = (tagFile.Tag.FirstPerformer != null) ? tagFile.Tag.FirstPerformer : "[No Artist]";
                tempAlbum = (tagFile.Tag.Album != null) ? tagFile.Tag.Album : "[No Album]";
                tempGenre = (tagFile.Tag.FirstGenre != null) ? tagFile.Tag.FirstGenre : "[No Genre]";
                tempYear = (tagFile.Tag.Year.ToString() != "0") ? tagFile.Tag.Year.ToString() : "[No Year]";
                Song tempSong = new Song(file, tempTitle, tempArtist, tempAlbum, tempGenre, tempYear);
                return tempSong;
        }
Exemple #2
0
        public void DoSetAlbumArt(Song song)
        {
            string songAlbumArt = song.FileLocation;

            TagLib.File f = TagLib.File.Create(songAlbumArt);
            if (f.Tag.Pictures.Length > 0)
            {
                TagLib.IPicture pic = f.Tag.Pictures[0];
                MemoryStream ms = new MemoryStream(pic.Data.Data);
                if (ms != null && ms.Length > 4096)
                    ms.Seek(0, SeekOrigin.Begin);
                {
                    currentAlbumArtBMI = new BitmapImage();
                    currentAlbumArtBMI.BeginInit();
                    currentAlbumArtBMI.StreamSource = ms;
                    currentAlbumArtBMI.EndInit();
                }
                ImageBrush imgBrush = new ImageBrush();
                imgBrush.ImageSource = currentAlbumArtBMI;
                MainWindowGrid.Background = imgBrush;
            }
            else
            {
                ImageBrush imgBrush = new ImageBrush();
                imgBrush.ImageSource = placeholderImage;
                imgBrush.Opacity = 0.4;
                MainWindowGrid.Background = imgBrush;
            }
        }
Exemple #3
0
 // Sets the window title to the current song name & artist.
 public void DoSetWindowTitle(Song song)
 {
     this.Title = song.SongTitle+ " - " +song.SongArtist;
 }
Exemple #4
0
 // Grabs a song from the library (currently selected) and loads it up into the mediaPlayer - then it sets album artwork and window title before playing it.
 public void DoLoadSongFromLibrary(Song song)
 {
     mediaPlayer.Open(new Uri(song.FileLocation));
     mediaPlayerIsPlaying = false;
     DoSetAlbumArt(song);
     DoSetWindowTitle(song);
     DoPlaySong();
 }
 public void RandomSong()
 {
     Random rnd = new Random();
     int randomTrack = rnd.Next(0, dtgLibrary.Items.Count);
     dtgLibrary.SelectedIndex = randomTrack;
     currentSong = (Song)dtgLibrary.SelectedItem;
 }
 public void PreviousSong()
 {
     if(dtgLibrary.SelectedIndex==0)
     {
         dtgLibrary.SelectedIndex = dtgLibrary.Items.Count -1;
         currentSong = (Song)dtgLibrary.SelectedItem;
     }
     else
     {
         dtgLibrary.SelectedIndex--;
         currentSong = (Song)dtgLibrary.SelectedItem;
     }
 }
 public void NextSong()
 {
     dtgLibrary.SelectedIndex++;
     currentSong = (Song)dtgLibrary.SelectedItem;
 }
 public void dtgLibrary_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     currentSong = (Song)dtgLibrary.SelectedItem;
     if (songSelected != null)
         songSelected(this, null);
 }