资源描述:
《c#编写的音乐播放器》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、主要代码:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.IO;usingSystem.Media;usingSystem.Drawing.Drawing2D;usingSystem.Data.OleDb;namespaceMusicPlay
2、er{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}string[]MusicFileNames;boolSingleLoop=true;boolAllLoop=true;boolnoramal=true;boolRandomLoop=true;#region//播放privatevoidbtnPlay_Click(objectsender,EventArgse){noramal=true;if(this.axWindowsMed
3、iaPlayer1.Ctlcontrols.currentPosition==0){if(this.listView1.Items.Count>0){timer1.Start();if(this.listView1.SelectedItems.Count>0){intiPos=this.listView1.SelectedItems[0].Index;stringFileName=this.listView1.Items[iPos].SubItems[2].Text;this.axWindowsMediaPlaye
4、r1.URL=FileName;}}else{MessageBox.Show("请选择歌曲!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);}}else{this.axWindowsMediaPlayer1.Ctlcontrols.play();}}#endregion#region//停止privatevoidbtnStop_Click(objectsender,EventArgse){timer1.Stop();if(this.listView
5、1.Items.Count>0){if(this.listView1.SelectedItems.Count>0){timer1.Enabled=false;axWindowsMediaPlayer1.Ctlcontrols.stop();}}else{MessageBox.Show("请选择歌曲!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);}}#endregion#region//暂停privatevoidbtnPause_Click(obj
6、ectsender,EventArgse){timer1.Stop();if(this.listView1.Items.Count>0){if(this.listView1.SelectedItems.Count>0){timer1.Enabled=false;axWindowsMediaPlayer1.Ctlcontrols.pause();}}else{MessageBox.Show("请选择歌曲!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
7、;}}#endregion#region//上一首privatevoidbtnLast_Click(objectsender,EventArgse){if(this.listView1.SelectedItems.Count>0){intiPos=this.listView1.SelectedItems[0].Index;if(iPos>0){this.listView1.Items[iPos-1].Selected=true;stringFileName=this.listView1.Items[iPos-1].
8、SubItems[2].Text;this.axWindowsMediaPlayer1.URL=FileName;}else{MessageBox.Show("这已经是第一首歌曲了!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);}}else{MessageBox.Show("请选择歌曲!"