音乐播放器毕业论文

2026/1/27 6:36:14

淮阴师范学院毕业论文(设计)

private void myListBox_MouseDown(object sender, MouseEventArgs e) {

if (this.myListBox.thisIndex != -1) {

if (e.Button == System.Windows.Forms.MouseButtons.Right) {

this.myListBox.ContextMenuStrip = this.cmsListBox; } } }

图5-2播放列表

5.3 播放控制模块

播放是音乐播放器最重要的功能。本程序使用Windows Media Player命名空间中定义的属性和方法来实现歌曲的播放、暂停、上下去切换等。其核心代码如下: private void initialBtn()

{

if (playStatue == MediaPlayer.PlayStatue.播放)

- 20 -

淮阴师范学院毕业论文(设计)

{ //正在播放,暂停图片

btnPlay.Image = Image.FromFile(\); }

else if (playStatue == MediaPlayer.PlayStatue.暂停 || playStatue == MediaPlayer.PlayStatue.停止) {//开始播放图片

btnPlay.Image = Image.FromFile(\); }

if (this.boolVolumn) {

this.btnVolumn.Image = Image.FromFile(\); } else

this.btnVolumn.Image = Image.FromFile(\);

}

private void nextSongPlay() {

//下一曲

if (playStyle == MediaPlayer.PlayStyle.随机播放)

{//选择随机播放时就产生一个随机数组,播放记录,根据数组,上一曲下一曲都有用

if (randomIndex + 1 >= randomList.Count) {

randomSongPlay(); } else

this.myListBox.doubleClickIndex = (int)randomList[++randomIndex];

}

else if (playStyle == MediaPlayer.PlayStyle.顺序播放) {

this.myListBox.doubleClickIndex++; if (this.myListBox.doubleClickIndex >= this.myListBox.Items.Count) {

playStatue = MediaPlayer.PlayStatue.停止; this.myListBox.doubleClickIndex = this.myListBox.Items.Count - 1;

- 21 -

淮阴师范学院毕业论文(设计)

stop();

initialBtn(); return; } } else

{//下一曲,如果到底,将播放第一首歌曲,全部循环 this.myListBox.doubleClickIndex++; if (this.myListBox.doubleClickIndex >= this.myListBox.Items.Count)

{//转第一首

this.myListBox.doubleClickIndex = 0; } }

btnChangeSong(); initialBtn();

}

private void lastSongPlay() {

if (playStyle == MediaPlayer.PlayStyle.随机播放 && randomIndex >= 1) {

this.myListBox.doubleClickIndex = (int)randomList[--randomIndex]; }

else if (playStyle == MediaPlayer.PlayStyle.顺序播放) {

this.myListBox.doubleClickIndex--;

if (this.myListBox.doubleClickIndex <= -1) {

this.myListBox.doubleClickIndex = 0;

playStatue = MediaPlayer.PlayStatue.停止; stop();

initialBtn(); return; } } else {

- 22 -

淮阴师范学院毕业论文(设计)

this.myListBox.doubleClickIndex--;

if (this.myListBox.doubleClickIndex <= -1) {//转最后一首

this.myListBox.doubleClickIndex = this.myListBox.Items.Count - 1; } }

btnChangeSong(); }

5.4 音量控制模块

通过调节音量大小来达到歌曲播放的最佳状态。可以调用API函数 SENDMESSAGE APPCOMMAND_VOLUME_MUTE和TrackBar 类来实现音量控制。代码如下: private void btnVolumn_Click(object sender, EventArgs e) {

IniUtility.FilePath = Application.StartupPath + \; if (this.boolVolumn) {

player.setAudioOnOff(\); this.boolVolumn = false;

IniUtility.WriteIniKey(\, \, \); } else {

player.setAudioOnOff(\); this.boolVolumn = true;

IniUtility.WriteIniKey(\, \, \); }

initialBtn(); }

private void myTBVolumn_Scroll(object sender, EventArgs e) {

- 23 -


音乐播放器毕业论文.doc 将本文的Word文档下载到电脑
搜索更多关于: 音乐播放器毕业论文 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219