欢迎来到天天文库
浏览记录
ID:55635138
大小:16.25 KB
页数:11页
时间:2020-05-21
《c#课程设计报告音乐播放器.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、ViscualC#编程实例一、任务目标通过建立实例“音乐播放器”,来掌握windows应用窗体。二、功能实现实现的功能有:播放模式:顺序,列表,随机,单曲。添加文件:添加单个文件,添加文件夹。删除文件:选中的,重复的,错误的以及全部。播放歌曲:播放,暂停。可以添加的文件有*.MP3,*.Wma,*.swf,*.wmv,*.avi文件。三、关键代码publicpartialclassForm1:Form{privatevoidAddFiles(){this.axWindowsMediaPlayer1.currentPlaylist.clear();listVi
2、ew1.Items.Clear();listView1.BeginUpdate();Class1lf=newClass1();ListViewItem[]lvi=lf.searchDirectorFile(this.folderBrowserDialog1.SelectedPath);for(inti=0;i3、1.currentPlaylist.appendItem(this.axWindowsMediaPlayer1.newMedia(lvi[i].SubItems[2].Text));this.listView1.Items.Add(lvi[i]);}listView1.EndUpdate();}publicForm1(){InitializeComponent();this.axWindowsMediaPlayer1.stretchToFit=true;this.axWindowsMediaPlayer1.settings.setMode("loop",tr4、ue);using(RegistryKeyuserKey=Application.UserAppDataRegistry){if((this.folderBrowserDialog1.SelectedPath=userKey.GetValue("MyMedia")asstring)==null){this.folderBrowserDialog1.SelectedPath=Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);}AddFiles();}}privatevoidtoolStri5、pButton1_Click(objectsender,EventArgse){if(this.folderBrowserDialog1.ShowDialog()==DialogResult.OK){AddFiles();}}privatevoidtoolStripButton2_Click(objectsender,EventArgse){if(this.openFileDialog1.ShowDialog()==DialogResult.OK){this.axWindowsMediaPlayer1.currentPlaylist.clear();list6、View1.Items.Clear();listView1.BeginUpdate();Class1lf=newClass1();string[]strFile=this.openFileDialog1.FileNames;for(inti=0;i7、ylist.appendItem(this.axWindowsMediaPlayer1.newMedia(lvi.SubItems[2].Text));this.listView1.Items.Add(lvi);}listView1.EndUpdate();}}privatevoidtimer1_Tick(objectsender,EventArgse){System.Randomrdm=newRandom(unchecked((int)DateTime.Now.Ticks));switch(this.axWindowsMediaPlayer1.playSt8、ate){caseWMPLib.WMPPlaySta
3、1.currentPlaylist.appendItem(this.axWindowsMediaPlayer1.newMedia(lvi[i].SubItems[2].Text));this.listView1.Items.Add(lvi[i]);}listView1.EndUpdate();}publicForm1(){InitializeComponent();this.axWindowsMediaPlayer1.stretchToFit=true;this.axWindowsMediaPlayer1.settings.setMode("loop",tr
4、ue);using(RegistryKeyuserKey=Application.UserAppDataRegistry){if((this.folderBrowserDialog1.SelectedPath=userKey.GetValue("MyMedia")asstring)==null){this.folderBrowserDialog1.SelectedPath=Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);}AddFiles();}}privatevoidtoolStri
5、pButton1_Click(objectsender,EventArgse){if(this.folderBrowserDialog1.ShowDialog()==DialogResult.OK){AddFiles();}}privatevoidtoolStripButton2_Click(objectsender,EventArgse){if(this.openFileDialog1.ShowDialog()==DialogResult.OK){this.axWindowsMediaPlayer1.currentPlaylist.clear();list
6、View1.Items.Clear();listView1.BeginUpdate();Class1lf=newClass1();string[]strFile=this.openFileDialog1.FileNames;for(inti=0;i7、ylist.appendItem(this.axWindowsMediaPlayer1.newMedia(lvi.SubItems[2].Text));this.listView1.Items.Add(lvi);}listView1.EndUpdate();}}privatevoidtimer1_Tick(objectsender,EventArgse){System.Randomrdm=newRandom(unchecked((int)DateTime.Now.Ticks));switch(this.axWindowsMediaPlayer1.playSt8、ate){caseWMPLib.WMPPlaySta
7、ylist.appendItem(this.axWindowsMediaPlayer1.newMedia(lvi.SubItems[2].Text));this.listView1.Items.Add(lvi);}listView1.EndUpdate();}}privatevoidtimer1_Tick(objectsender,EventArgse){System.Randomrdm=newRandom(unchecked((int)DateTime.Now.Ticks));switch(this.axWindowsMediaPlayer1.playSt
8、ate){caseWMPLib.WMPPlaySta
此文档下载收益归作者所有