Ejemplo n.º 1
0
        private void Player_StatusChanged(object sender, PlayerStatusChangedEvent e) // Implementation of the player status changed event
        {
            if (e.SongHasChanged)                                                    // If the song has changed, update the GUI
            {
                TimeSlider.Maximum = Tab.Player.TotalDuration;

                TimeSpan ts  = TimeSpan.FromMilliseconds(Tab.Player.TotalDuration);
                string   str = ts.ToString(@"hh\:mm\:ss");
                if (str[0] == '0' && str[1] == '0')
                {
                    str = str.Substring(3, str.Length - 3);
                }
                TotalDuration_Label.Content = str;

                Title.Content  = e.CurrentSong.Title;
                Artist.Content = e.CurrentSong.Artist;
                Cover.Source   = ID3Tag.GetCover(e.CurrentSong);
            }
            if (e.IsPlaying)  // If it's only a play/pause event, update the play/pause button
            {
                Play.Content = "||";
            }
            else
            {
                Play.Content = "|>";
            }
        }
Ejemplo n.º 2
0
        private void ScanThread(object sender, DoWorkEventArgs e)
        {
            string       path   = ((Tuple <string, SearchOption>)e.Argument).Item1;
            SearchOption option = ((Tuple <string, SearchOption>)e.Argument).Item2;

            Stopwatch watch = new Stopwatch();

            watch.Start();
            List <string> files;

            try
            {
                files = Directory.EnumerateFiles(path, "*.*", option)  // List all mp3/wav files
                        .Where(s => s.EndsWith(".mp3") || s.EndsWith(".wav")).ToList();
            }
            catch (UnauthorizedAccessException)
            {
                MessageBox.Show("You don't have access to this folder !");
                return;
            }

            foreach (String pathStr in files)
            {
                Song song = new Song(pathStr); // Create a song object
                ID3Tag.Read(song);             // Read the metadata
                int i = 0;
                if (Songs.Count >= 1)
                {
                    while ((song.Title.CompareTo(Songs[i].Title) > 0) && (i < Songs.Count - 1))
                    {
                        i++;
                    }
                }
                Application.Current.Dispatcher.Invoke(new ThreadStart(delegate
                {
                    Songs.Insert(i, song);
                }));
            }
            watch.Stop();
            Console.WriteLine("Time: " + watch.ElapsedMilliseconds);
        }