public Playlist(string directoryPath) { this.songs = new List<Song>(); DirectoryInfo dir = new DirectoryInfo(directoryPath); if(dir.GetFiles().Length != 0) { foreach (var file in dir.GetFiles()) { if(file.Extension == ".mp3") { this.songs.Add(new Song(file.FullName)); } } } if(this.songs.Count > 0) { this.currentSong = this.songs[0]; } }
public Playlist() { this.songs = new List<Song>(); this.currentSong = new Song(); }
public void SelectSongIndex(int index) { this.currentSong = this.songs[index]; }
public void Previous() { this.currentSong = PreviousSong; }
public void Next() { this.currentSong = NextSong; }
public void AddSong(Song song) { this.songs.Add(song); if (this.currentSong.Path == "Unknown") { this.currentSong = song; } SongAdded(this, EventArgs.Empty); }
private void btnAddSong_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Audio Files |*.mp3"; bool? result = openFileDialog.ShowDialog(); if(result == true) { try { Song song = new Song(openFileDialog.FileName); this.playlist.AddSong(song); lstSongs.Items.Refresh(); SetBindings(); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } } }