音乐播放器开发模块

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

音乐播放器开发文档

1.动能介绍

开始菜单包含:a.添加音乐文件b.添加音乐文件夹c.添加背景图片d.退出播放模式:a.单曲循环 b.顺序循环 c.列表播放 d.随机播放

透明度:透明百分之几或不透明

界面设置:迷你模式

关于:版本信息

2、代码讲解

全局变量:private SoundPlayer Player = new SoundPlayer();

private SoundPlayer SencondPlayer = new SoundPlayer();

Image[] image = new Image[500];//存放图片数组

private int Imagecount = 0;//计算背景图片数

private int order = 0;//存储图片总数

private int fileCount = 0;//数组中计算音乐文件数

private int fileCount1 = 0;//文件系数

string[] musicfile = new string[500];//存放音乐文件

int selectOne = 0;//双击事件选择的音乐的序号

static int stop = 2;//判断是暂停还是播放

static double CurrentPosition = 0;//获得文件播放的位置

static int State = 0;//当前状态等于时进行单曲循环,等于零的时候进行顺序播放,//当前状态等于时为随机播放//当前状态等于时为列表播放

OpenFileDialog openfile = new OpenFileDialog();//打开本地磁盘对话框

添加音乐文件

private void添加文件ToolStripMenuItem1_Click(object sender, EventArgs e)

{

fileCount1++;

openfile.Filter = "|*.mp3";

openfile.Multiselect = true;//支持多行文件

try

{

if (DialogResult.OK == openfile.ShowDialog())

{

musicfile[fileCount] = openfile.FileName;

FileInfo fileinfo = new FileInfo(musicfile[fileCount]);

//FileInfo类是将文件去相对路径

string filename = fileCount1.ToString() + "_" + ;//使音乐名前加序号并只取文件名

this.listBox1.Items.Add(filename);//将文件多行显示在列表中

this.musicname.Text = ;

PlayAndStop(fileCount); //启动MP3播放器

fileCount++;

}

}

catch (Exception)

{

MessageBox.Show(musicfile[fileCount].ToString());

}

}

添加音乐文件夹

private void添加文件夹ToolStripMenuItem1_Click(object sender, EventArgs e)

{

FolderBrowserDialog folder = new FolderBrowserDialog();//文件夹初始化

folder.ShowDialog();

string[] file = Directory.GetFiles(folder.SelectedPath.ToString(), "*.MP3");//使用数组存得到的文件

int fileName = 0;

try

{

foreach (string Music in file)

{

fileCount1++;

FileInfo f = new FileInfo(file[fileName]);//读取文件

musicfile[fileCount] = file[fileName];

fileName++;

fileCount++;//数组存文件数

string total = fileCount1.ToString() + "_" + ;//只取f中的文件名this.listBox1.Items.Add(total);

}

}

catch (Exception)

{

MessageBox.Show("输入的音乐总数超出!");

}

}

添加背景图片

private void添加背景图片ToolStripMenuItem1_Click(object sender, EventArgs e)

{

FolderBrowserDialog folder = new FolderBrowserDialog();

folder.ShowDialog();

string[] BGfile = Directory.GetFiles(folder.SelectedPath.ToString(), "*.jpg");

foreach (string pic in BGfile)

{

image[order] = Image.FromFile(pic);

order++;

}

this.timer1.Enabled = true;//启动定时器

}

定时器

private void timer1_Tick(object sender, EventArgs e)

{

this.BGpicture.Image = image[Imagecount];

if (Imagecount >= order-1)

相关文档
最新文档