예제 #1
0
 private void playSong(Song song)
 {
     //Console.WriteLine(searchdir + "\\" + song.getFilename());
     mediaPlayer.Open(new System.Uri(searchdir + "\\" + song.getFilename()));
     ArtistName.Content = song.Artist;
     SongName.Content = song.Title;
     MainWin.Title = song.Artist + " - " + song.Title;
     mediaPlayer.Play();
     if (isPaused)
     {
         togglePlayPause();
     }
 }
예제 #2
0
        private void genCol()
        {
            List<Song> old = songs;
            songs = new List<Song>();
            TagLib.File temp;
            foreach (string s in Directory.GetFiles(searchdir, "*.mp3"))
            {
                try
                {
                    temp = TagLib.File.Create(s);
                    Song song;
                    song = new Song { Artist = (temp.Tag.Performers.Length == 0 ? "Unknown" : string.Join(";", temp.Tag.Performers)),
                                      Title = (temp.Tag.Title == null ? System.IO.Path.GetFileNameWithoutExtension(s) : temp.Tag.Title),
                                      Album = (temp.Tag.Album),
                                      Genre = (string.Join(";", temp.Tag.Genres)) };
                    song.setFilename(System.IO.Path.GetFileName(s));
                    songs.Add(song);
                }
                catch (Exception e)
                {
                    MessageBox.Show("There was an error reading your music: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                }

            }
            if (songs.Count == 0)
            {
                MessageBox.Show("You have no music to play!\nPlease put some music in " + searchdir + " and then run this application.\nPlease note, the files must be in .mp3 form", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                if (searchdir == defaultsearchdir)
                {
                    Environment.Exit(0);
                }
                else
                {
                    searchdir = prevSearchDir;
                    songs = old;
                    return;
                }
            }
            songList.ItemsSource = songs;
            advanceSong();
        }