曾经做过一个简单的播放器,可以这样做,添加mp3文件时先取得mp3的信息
方法在这里http://hi.baidu.com/feitianchong1/blog/item/dadc41a6b5ae679cd04358c4.html
同时添加到数据库,或者是xml文件就行了,我做的时候是用xml当数据库的
http://hi.baidu.com/feitianchong1/blog/item/0c01d42b33880a24d52af1b0.html

解决方案 »

  1.   


            //添加音乐
            private void btn_Add_Click(object sender, EventArgs e)
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.AddExtension = true;
                ofd.CheckFileExists = true;
                ofd.CheckPathExists = true;
                ofd.Filter = "所有影音文件(*.mp3;*.wma;*.wav;*.avi;*.wmv;*.mpeg;*.mpg;*.dat;*.rm;*.rmvb)|*.mp3;*.dat;*.wma;*.wav;*.avi;*.wmv;*.mpeg;*.mpg;*.rm;*.rmvb";
                ofd.FilterIndex = 2;            if (ofd.ShowDialog() == DialogResult.OK)
                {
                    con.axWindowsMediaPlayer1.URL = ofd.FileName;//获得音乐文件的路径
                    FileInfo fi = new FileInfo(ofd.FileName);
                    con.axWindowsMediaPlayer1.Ctlcontrols.play();//播放
                    this.lb_Playing.Text = string.Format("    Playing:{0}",fi.Name);
                    FirstSet();//播放初始设置                //验证歌曲重复,并添加到播放列表
                    DataSet _dsSong = new DataSet();
                    _dsSong.ReadXml(Application.StartupPath + "\\musicList.xml", XmlReadMode.ReadSchema);
                    DataView _dv = new DataView(_dsSong.Tables[0]);
                    _dv.RowFilter = string.Format("mUrl='{0}'",clsTool.SqlInsertEncode(ofd.FileName));
                    if (_dv.ToTable().Rows.Count == 0)
                        XMLAdd();//添加到xml
                    else
                        MessageBox.Show("The selected song is already exist");
                    //加载xml中播放列表
                    PlayListBind();
                }
            }        //播放初始化
            private void FirstSet()
            {
                count = 0;
                int total = Convert.ToInt32(Math.Truncate(con.axWindowsMediaPlayer1.currentMedia.duration)*10);  //进度条总长度
                prog_elapsed.Maximum = total;
                prog_remain.Maximum = total;
                this.prog_elapsed.Value = 0;
                this.prog_remain.Value = total;
                this.lb_currTotal.Text = con.axWindowsMediaPlayer1.currentMedia.durationString;//总时间
                this.slider_prog.Maximum = total;
                this.timer1.Enabled = true;
                this.cb_HideContr.Checked = true;
            }