Exemplo n.º 1
0
        private void MusicPanel_DragDrop(object sender, DragEventArgs e)
        {
            string[] s = (string[])e.Data.GetData(DataFormats.FileDrop, false);
            SamePaths.AddRange(s.Where(a => Path.GetExtension(a) == ".mp3"));
            Paths = SamePaths.Distinct().ToList();
            var pl = WMPlayer.currentPlaylist;

            for (int i = start; i < Paths.Count; i++)
            {
                var mediaItem = WMPlayer.newMedia(Paths[i]);
                pl.appendItem(mediaItem);
            }

            for (int i = start; i < Paths.Count; i++)
            {
                var newMusic = new Music
                {
                    Title  = Path.GetFileNameWithoutExtension(Paths[i]),
                    MPath  = Paths[i],
                    Length = GetDuration(Paths[i]).ToString(@"mm\:ss")
                };
                start++;
                var MusicControl = new MusicNameControl(newMusic);
                MusicControl.Selected += OnSelect;
                MusicControl.Playing  += Play;
                MusicPanel.Controls.Add(MusicControl);
                CountLabel.Text = start.ToString();
                TimeSpan time = GetDuration(Paths[i]);
                sum += time;
                DurationLabel.Text = sum.ToString(@"hh\:mm\:ss");
            }
        }
Exemplo n.º 2
0
        private void MusicAdd()
        {
            openFileDialog.Filter      = "MP3 files (*.mp3)|*.mp3";
            openFileDialog.Multiselect = true;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                SamePaths.AddRange(openFileDialog.FileNames);
                Paths = SamePaths.Distinct().ToList();
                var pl = WMPlayer.currentPlaylist;
                for (int i = start; i < Paths.Count; i++)
                {
                    var mediaItem = WMPlayer.newMedia(Paths[i]);
                    pl.appendItem(mediaItem);
                }


                for (int i = start; i < Paths.Count; i++)
                {
                    var newMusic = new Music
                    {
                        Title  = Path.GetFileNameWithoutExtension(Paths[i]),
                        MPath  = Paths[i],
                        Length = GetDuration(Paths[i]).ToString(@"mm\:ss"),
                    };
                    start++;
                    var MusicControl = new MusicNameControl(newMusic);
                    MusicControl.Selected += OnSelect;
                    MusicControl.Playing  += Play;
                    MusicPanel.Controls.Add(MusicControl);
                    CountLabel.Text = start.ToString();
                    TimeSpan time = GetDuration(Paths[i]);
                    sum += time;
                    DurationLabel.Text = sum.ToString(@"hh\:mm\:ss");
                }
            }
        }