//chuc nag keo tha private void ds_DragDrop(object sender, DragEventArgs e) { try { ds.Items.Clear(); //tao playlist chua cac bai hat duoc chon plItems = axWindowsMediaPlayer1.playlistCollection.getByName(myPlaylist); pl = axWindowsMediaPlayer1.playlistCollection.newPlaylist(myPlaylist); //them vao listview va thu vien WMP string[] s = (string[])e.Data.GetData(DataFormats.FileDrop, false); FileInfo f; for (int i = 0; i < s.Length; i++) { f = new FileInfo(s[i]); ds.Items.Add(f.Name); ListViewItem item = new ListViewItem(s[i]); lb2.Items.Add(f.FullName); m1 = axWindowsMediaPlayer1.newMedia(s[i]); pl.appendItem(m1); } play.Hide(); pause.Show(); axWindowsMediaPlayer1.currentPlaylist = pl; axWindowsMediaPlayer1.Ctlcontrols.play(); axWindowsMediaPlayer1.playlistCollection.remove(pl); } catch (Exception) { //MessageBox.Show("Không Cho Phép Kéo Thả"); } }
private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { axWindowsMediaPlayer1.Ctlcontrols.stop(); TreeNode selnode = e.Node; int i = selnode.Index; string[] s = new string[list[i].Items.Count]; lb2.Items.Clear(); listView2.Items.Clear(); listView1.Items.Clear(); ds.Items.Clear(); for (int j = 0; j < list[i].Items.Count; j++) { s[j] = list[i].Items[j].ToString(); lb2.Items.Add(s[j]); listView2.Items.Add(Path.GetFileNameWithoutExtension(s[j])); } plItems = axWindowsMediaPlayer1.playlistCollection.getByName(myPlaylist); if (plItems.count == 0) { pl = axWindowsMediaPlayer1.playlistCollection.newPlaylist(myPlaylist); } else { pl = plItems.Item(0); } int q = 0; foreach (string file in s) { ListViewItem item = new ListViewItem(s[q]); ds.Items.Add(Path.GetFileNameWithoutExtension(item.ToString())); q++; m1 = axWindowsMediaPlayer1.newMedia(file); pl.appendItem(m1); } //choi nhac axWindowsMediaPlayer1.currentPlaylist = pl; axWindowsMediaPlayer1.Ctlcontrols.play(); axWindowsMediaPlayer1.playlistCollection.remove(pl); }
private void CreatePlayLis(OpenFileDialog open, ListView lv) { plItems = axWindowsMediaPlayer1.playlistCollection.getByName(myPlaylist); if (plItems.count == 0) pl = axWindowsMediaPlayer1.playlistCollection.newPlaylist(myPlaylist); else pl = plItems.Item(0); //them vao listview va thu vien WMP int i = 0; foreach (string file in open.FileNames) { ListViewItem item = new ListViewItem(open.FileNames[i]); lv.Items.Add(Path.GetFileNameWithoutExtension(item.ToString())); i++; m1 = axWindowsMediaPlayer1.newMedia(file); pl.appendItem(m1); } //choi nhac axWindowsMediaPlayer1.currentPlaylist = pl; axWindowsMediaPlayer1.Ctlcontrols.play(); axWindowsMediaPlayer1.playlistCollection.remove(pl); }