欢迎来到天天文库
浏览记录
ID:41126235
大小:50.00 KB
页数:5页
时间:2019-08-17
《MP3播放器源码》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.IO;namespaceEx182{publicpartialclassForm1:Form{privateboolbool_no_sound=false;//是否静音privateintnum_sound_value=0;//音量
2、privatestringstr_load_dir="";//文件目录publicForm1(){File.AppendAllText("LoadMusic.txt","");//打开文件,追加字符串InitializeComponent();str_load_dir=File.ReadAllText("LoadMusic.txt");if(str_load_dir!="")Loadmusics();}privatevoidLoadmusics(){try{//遍历打开的文件,将文件名添加到ListBox控件中,加入播放文件列表foreach(stringfilenameinDirec
3、tory.GetFiles(str_load_dir)){FileInfofi=newFileInfo(filename);if(fi.Extension==".*"
4、
5、fi.Extension==".wmv"
6、
7、fi.Extension==".mp3"
8、
9、fi.Extension==".wma"
10、
11、fi.Extension==".avi"){listBox1.Items.Add(fi.Name);axWindowsMediaPlayer1.currentPlaylist.insertItem(axWindowsMediaPlayer1.currentPlaylist.count,ax
12、WindowsMediaPlayer1.newMedia(filename));}}}catch{File.WriteAllText("LoadMusic.txt","");}}privatevoid打开ToolStripMenuItem_Click(objectsender,EventArgse){OpenFileDialogopen=newOpenFileDialog();//对话框对象//过滤条件open.Filter="所有文件.*
13、*.*
14、Wmv视频.wmv
15、*.wmv
16、歌曲.mp3
17、*.mp3
18、歌曲.wma
19、*.wma
20、文件.avi
21、*.avi";open.FilterIn
22、dex=1;if(open.ShowDialog()==DialogResult.OK){FileInfofi=newFileInfo(open.FileName);//获取文件inti;//将打开的文件添加到ListBox控件中for(i=0;i23、wsMediaPlayer1.currentPlaylist.insertItem(axWindowsMediaPlayer1.currentPlaylist.count,axWindowsMediaPlayer1.newMedia(open.FileName));}}}boolisplayer=true;privatevoidlabel3_Click(objectsender,EventArgse){if(isplayer){axWindowsMediaPlayer1.Ctlcontrols.pause();//暂停this.label3.Text="播放";isplayer=fal24、se;}else{axWindowsMediaPlayer1.Ctlcontrols.play();//播放this.label3.Text="暂停";isplayer=true;}}privatevoidlabel4_Click(objectsender,EventArgse){axWindowsMediaPlayer1.Ctlcontrols.stop();//停止}privatevoidlabel1_Click(objectsender,
23、wsMediaPlayer1.currentPlaylist.insertItem(axWindowsMediaPlayer1.currentPlaylist.count,axWindowsMediaPlayer1.newMedia(open.FileName));}}}boolisplayer=true;privatevoidlabel3_Click(objectsender,EventArgse){if(isplayer){axWindowsMediaPlayer1.Ctlcontrols.pause();//暂停this.label3.Text="播放";isplayer=fal
24、se;}else{axWindowsMediaPlayer1.Ctlcontrols.play();//播放this.label3.Text="暂停";isplayer=true;}}privatevoidlabel4_Click(objectsender,EventArgse){axWindowsMediaPlayer1.Ctlcontrols.stop();//停止}privatevoidlabel1_Click(objectsender,
此文档下载收益归作者所有