控制台C语言编写音乐播放器主要功能
- 格式:doc
- 大小:17.01 KB
- 文档页数:14
论文题目基于VC的MP3播放器设计与实现姓名学院学院专业计算机科学与技术指导教师讲师备注年月日基于VC的MP3播放器设计与实现作者姓名:指导教师:讲师单位名称:计算机科学与技术系专业名称:计算机科学与技术学校年月Design and Implementation of Mp3 PlayerBased on VCbySupervisor: Lecturer毕业设计(论文)任务书基于VC的MP3播放器设计与实现摘要本MP3播放器应用程序是一个基于Visual C++ 6.0 开发的一个多媒体软件,是建立在MCI(媒体控制接口)控制之上的软件。
该软件开发研究的目的主要是为了给人们娱乐和消遣用的;该软件实现的方法是通过调用MCI控制接口的相关函数,获取系统的控制信息,利用系统信息对MP3播放器的每一个动作进行控制。
现在为止,该软件到可以实现的功能是:该软件可以添加和播放多种音频文件格式,可以添加单个音频文件,也可以同时添加多个音频文件;对音频文件的操作有:播放音频文件、暂停、停止,可以选择播放下一首歌或前一首歌;可以对已经添加进入播放列表的音频文件进行删除或者添加新的音频文件;可以调节系统的音量的大小;该软件还可以显示当前播放的进度;可以隐藏或展开播放列表;本软件可以进行系统托管,隐藏主界面后,在任务栏创建托管图标;单击托管图标后可以重新弹出控制界面,并取消托管图标。
在系统托管或自动播放的情况下,该软件在播放完一首歌后可以自动跳转到下一首歌,并播放此音频文件。
关键词:媒体控制接口,多媒体,系统托管,控件,音频文件Design and Implementation of Mp3 PlayerBased on VCAbstractThe MP3 Player application programme is software that developed based on Visual C++ 6.0, and also is software that built on the control of MCI. The purpose of developing this software is for the entertainment and recreation of people. The way this software realized is transfer the correlation functions of MCI, and obtain the information of system control, using this information to control each movement of the MP3 Player.So far, the functions that software can realize are: The software can open and play different formats of audio-files,You can add the audio-file one by one or add many audio-files once; play the audio-files; pause; stop; play the following audio-file, and play the preceding audio-file. You can also delete the audio-files that the play list already have or add the new audio-file that the play-list does not exist. You can accommodate the volume of the system. The can show the progress that the current audio-file played. And can hide or outspread the play list. The software can trustee by the system, and will create a icon on the taskbar. When click the icon the interface will show again. While the current audio-file is playing over, it will jump to the next audio-file and play automatically.Key words: MCI,Media,System-Trustee,Controls,Audio-files目录毕业设计(论文)任务书 (I)摘要 (II)ABSTRACT......................................................................................... I II 第1章绪论 .. (1)1.1课题来源 (1)1.2课题描述 (1)1.3课题设计的思想 (1)1.4国内外的发展概况 (2)1.4.1 Winamp (2)1.4.2千千静听 (2)第2章用户需求分析 .................................... 错误!未定义书签。
Windows Media Player控件研究我的那个定时提醒程序中要用到它,初步使用问题已解决。
基本使用步骤如下:一、往控件箱中添加此控件:wmp.dll二、往窗体上拖控件三、wmp.URL=XXXX;wmp.play()即可。
平常应用就这三步就OK了。
但是,我想写个播放器的话,就遇到了一些问题。
在dotnet中使用非基于dotnet的控件,需要做一些额外的事,不过这些事vs 已经帮我们做好了,当我们拖了此控件进窗体时,vs会自动调用AxImp.exe,用它根据原有的dll或ocx生成一个用AxHost类包装的新的一组程序集(更为精确的描述见msdn),于是根据WMPLib.dll生成两个文件:AxInterop.WMPLib.dll、Interop.WMPLib.dll。
这两个文件中包含了转化后的类。
包装后的控件继承自System.Windows.Forms.AxHost。
这是第一个问题,控件怎么使用呢?如果是拖控件,很简单,无论如何都能有效的使用。
但是,如果手工new创建控件的实例呢?那就不一定了。
我做过种种实验,获得如下的结论:在非可视化类中无法创建有UI的控件的实例,或者是在没有把实例加入到一个可视化的容器中时。
我实验了下面的代码:AxWMPLib.AxWindowsMediaPlayer wmp=new AxWMPLib.AxWindowsMediaPlayer();this.Controls.Add(wmp);wmp.URL="约定.mp3";wmp.Ctlcontrols.play();这几行代码不一定能运行。
发现,如果这几行代码写在窗体的构造函数中,哪怕show出来都不能运行,只有写在Load或Load之后的事件中,并且把窗体show出来才有运行,否则会抛出一个错误:引发类型为“System.Windows.Forms.AxHost+InvalidActiveXStateException”的异常。
#include "FM_Main.h"#include"CTL.H"#include<stdio.h>#include<windows.h>#include<mmsystem.h>#include"GUI.h"#include"ERR_CheckEnter.h"#pragma comment(lib,"winmm.lib")#include "FM_CheckFile.c"#include"FM_Choose.c"#include"FM_List.c"#include "FM_Path.c"int Order=1; //初始时为第一首歌,随音乐切换而切换--nextsong() int NewOrder=0;int Amount = 0; //歌曲总量int begin; //自定义列表中开始序号int circulatemode=1; //循环模式int pp=0;int begintemp=0; //存储自定义列表边界int ww=-1; // 显示自定义列表当前播放信息int upordown=1; //判断切歌方向int firstup=0;int originvolume=500; //默认音量为500char v[40]="setaudio aa volume to 500"; //初始化音量void Init(){Order=1;NewOrder=0;Amount = 0;circulatemode=1;pp=0;begintemp=0;ww=-1;upordown=1;firstup=0;originvolume=500;}void ShowFileList(){if(begintemp==0)begintemp=begin;Amount = FM_CheckFile();begin = Amount;if(NewOrder==0){Show_GUI_EIGHT();FM_CheckFilePrint(0,Amount);}else{Show_GUI_EIGHT();FM_CheckFilePrint(Amount,begintemp);}};void ShowFileDetails(){int i=0;if(upordown==1){if(NewOrder!=0){Order=Amount+1+ww;ww++;}}if(upordown==2){if(firstup==0){if(NewOrder!=0){Order=Amount+1+ww;ww--;}firstup--;}else{if(NewOrder!=0){Order=Amount+1+ww;ww--;}}}firstup+=4;i=Order-1;printf(" 正在播放的音乐\n");printf("-------------------------------------------------------\n");printf(" 歌曲号歌曲名歌手名\n");printf("-------------------------------------------------------\n");printf(" %3d ",info[i].ID);printf(" %-20s ",info[i].song);printf(" %-10s\n",info[i].singer);printf("-------------------------------------------------------\n");}void Play(){if(NewOrder!=0)Order=Amount+1;char vol[10]="500";char v[40];char ch[200];sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);sprintf(v," setaudio aa volume to %s",vol);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa repeat",NULL,0,NULL);// getchar();}void Stop(){mciSendString ("pause aa",NULL,0,NULL);printf("歌曲播放已暂停,输入3继续播放,输入12退出\n\n");// getchar();}void Resume(){mciSendString ("resume aa",NULL,0,NULL);// getchar();}void FastForward(){int n=1;int m=0;int d=0;int minute;int second;char dd[60][20];char temp[20];do{printf("输入1快进:");scanf("%d",&n);mciSendString ("status aa position", dd[m], 20, 0); char ch[20];sprintf(ch,"%s",dd[m]);d=atoi(dd[m]);d+=5000;minute=(int)(((int)(d/1000))/60);second=(d/1000)-minute*60;itoa(d,dd[m],10);sprintf(temp,"seek aa to %s",dd[m]);mciSendString (temp,NULL,0,NULL);Play();m++;clrscr();ShowFileList();ShowFileDetails();Show_GUI_FOUR();printf("当前时间:%d:%02d \n",minute,second);}while(n==1);}void FastBack(){int n=1;int m=0;int d=0;int minute;int second;char dd[60][20];char temp[20];do{printf("输入1快退");scanf("%d",&n);mciSendString ("status aa position", dd[m], 20, 0); char ch[20];sprintf(ch,"%s",dd[m]);d=atoi(dd[m]);d-=5000;minute=(int)(((int)(d/1000))/60);second=(d/1000)-minute*60;itoa(d,dd[m],10);sprintf(temp,"seek aa to %s",dd[m]);mciSendString (temp,NULL,0,NULL);Play();m++;clrscr();ShowFileList();ShowFileDetails();Show_GUI_FOUR();printf("当前时间:%d:%02d \n",minute,second);}while(n==1);}void StopStop(){char temp[20];char ch[10];itoa(0,ch,10);sprintf(temp,"seek aa to %s",ch);mciSendString (temp,NULL,0,NULL);mciSendString ("pause aa",NULL,0,NULL);printf("点击1重新播放\n\n");}void VolumePlus(){int n=1;// int originvolume=500;char volume[10];char temp[40];while(n==1){printf("输入1增加音量,输入2退出音量增加模式 ");scanf("%d",&n);originvolume+=250;itoa(originvolume,volume,10);sprintf(temp," setaudio aa volume to %s",volume);mciSendString (temp,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);getchar();clrscr();ShowFileList();ShowFileDetails();Show_GUI_FOUR();printf("当前音量:%d\n",originvolume);}originvolume-=250;}void VolumeReduce(){int n=1;// int originvolume=500;char volume[10];char temp[40];while(n==1){printf("输入1降低音量,输入2退出音量降低模式 ");scanf("%d",&n);originvolume-=250;itoa(originvolume,volume,10);sprintf(temp,"setaudio aa volume to %s",volume);mciSendString (temp,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);// getchar();clrscr();ShowFileList();ShowFileDetails();Show_GUI_FOUR();printf("当前音量:%d\n",originvolume);}originvolume+=250;}void PreSong(){if(NewOrder==0){if(circulatemode==1){if(Order<1){Order=1;char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);// getchar();}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);// getchar();}}if(circulatemode==2){if(Order<1){Order=Amount;char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);// getchar();}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);// getchar();}}}else{Order=Amount+pp;if(circulatemode==1){if(Order<Amount){Order=Amount;char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);// getchar();}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);// getchar();}}if(circulatemode==2){if(Order<Amount){Order=begin;char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);// getchar();}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);// getchar();}}pp--;}upordown=2;}void NextSong(){if(NewOrder==0){if(circulatemode==1){if(Order>Amount){Order=Amount;char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);// getchar();}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);// getchar();}}if(circulatemode==2){if(Order>Amount)//////////////////////////////////////////////{Order=1;char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);// getchar();}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);// getchar();}}}else{Order=Amount+pp;if(circulatemode==1){if(Order<Amount)/////////////////////有问题{Order=Amount;char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order+1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);// getchar();}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order+1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);// getchar();}}if(circulatemode==2){if(Order<Amount)//有问题{Order=begin;char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order+1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);// getchar();}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order+1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);// getchar();}}pp++;}upordown=1;}void SelectCirculMode(){int i=0;Show_GUI_SEVEN();scanf("%d",&i);if(i==1)circulatemode=1;if(i==2)circulatemode=2;}void SaveExit(){/*char dd[20];char log[50]={"testlog!!!"};mciSendString ("status aa position", dd, 20, 0);int d;d=atoi(dd);FILE *fp = NULL;fp = fopen("D:\\SaveLog.txt","a");fwrite(log,1,50,fp);*/}void PlayOperation(){int d;re: clrscr();ShowFileList();ShowFileDetails();Show_GUI_FOUR();printf("请选择要进行的操作:");epo:scanf("%d",&d);fflush(stdin);if(ERR_CheckEntero(d)){switch(d){case 1:Play();goto re;case 2:Stop();goto re;case 3:Resume();goto re;case 6:FastForward();goto re;case 8:FastBack();goto re;case 4:StopStop();goto re;case 9:VolumePlus();goto re;case 10:VolumeReduce();goto re;case 5:Order--;PreSong();goto re;case 7:Order++;NextSong();goto re;case 12:ChooseSong();goto re;case 11:SelectCirculMode();goto re;case 13:mciSendString("close aa", NULL, 0, NULL);return;case 14:SaveExit();// getchar();}}else{goto epo;}};void NewOperation(){ee: int i=0;printf("请选择要进行的操作:");scanf("%d",&i);fflush(stdin);switch(i){case 1:FM_CheckFilePrint(0,Amount);begin = FM_Choose(Amount,begin);break;case 2:begin = FM_Path(begin);break;case 3:break;default:printf("输入有误\n");goto ee;}};void ShowNewList(){FM_List(begin,Amount);NewOrder=Amount+1;PlayOperation();}void ChooseSong(){int id = 0;printf("请输入歌曲号:");scanf("%d",&id);if(id<1||id>Amount){printf("选择歌曲不存在!\n");}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[id-1].add);mciSendString(ch,NULL,0,NULL);mciSendString("play aa repeat",NULL,0,NULL);}}。
include <windows.h> #include <stdio.h>#include <stdlib.h>#include <string.h>#include <conio.h>unsigned frequency[100];char hight[100];unsigned time[100];unsigned rate;void main(){voidset(unsignedf[],charh[],unsignedt[],int r,int num);void music(unsigned f[],unsigned t[],intnum);int flag=0;FILE *f1;int i,n,menu;char FileName[30];while(1){f1=NULL;i=n=0;printf("本程序采用编码的形式播放音乐。
\n");printf("\n用记事本编辑乐谱,然后通过输入文件名播放音乐\n");printf("乐谱文件可以自创,也可以抄别人的\n");printf("\n现在可以先输入数字再按回车播放音乐:\n");printf("1播放指定音乐music1\n");printf("2播放指定音乐music2\n");printf("3通过程序文件名播放音乐\n");printf("4退出\n");while(1){printf("menu=");scanf("%d",&menu);if(menu==1) {strcpy(FileName,"music1.txt");break;}if(menu==2){strcpy(FileName,"music2.txt");break;}if(menu==3){scanf("%s",FileName);break;}if(menu==4)exit(0);}printf("\n该文件的音乐编码如下:\n");if((f1=fopen(FileName,"r"))==NULL){ printf("不能打开文件!\n");exit(1);}fscanf(f1,"%d",&rate);while(!feof(f1)&&flag!=1){fscanf(f1," %d%c%d",&frequency[i],&hight[i],&time[i]);printf("%d%c%d",frequency[i],hight[i],time[i]);if(time[i]!=-1){i++;n++;}elseflag=1;}printf("\n");set(frequency,hight,time,rate,n);music(frequency,time,n);fclose(f1);}getch();}void set(unsigned f[],char h[],unsigned t[],int r,int num){int i,k;for(i=0;i<num;i++){t[i]=t[i]*r;switch(h[i]){case 'H':k=4;break;case 'M':k=2;break;case 'L':k=1;}switch(f[i]){case 1: f[i]=262*k; break;case 2: f[i]=296*k; break;case 3: f[i]=330*k; break;case 4: f[i]=349*k; break;case 5: f[i]=392*k; break; case 6: f[i]=440*k; break;case 7: f[i]=494*k; break;} }}voidmusic(unsignedf[],unsignedt[],intnum){int i;for(i=0;i<num;i++){Beep(f[i],t[i]);}。
闽江学院本科毕业论文(设计)题目基于C#实现音乐播放器功能学生姓名学号系别计算机科学系年级专业通信工程指导教师职称教授完成日期摘要现代经济开展迅速,科学技术也在不断开展进步,日益繁荣的计算机信息技术带给人们许多便利。
音乐作为人们生活中常见的娱乐方式,也在计算机普及的冲击下发生了革新。
随着音乐的数字化,媒体播放器也往更高质方向进步。
最常见的Windows media player——因其强大的音频解码功能而备受青睐。
当你也想自己动手制作一个能够简单播放歌曲的音乐播放器,体验一下编程的乐趣的时候你可以使用Visual stdio2021工具。
本文的目的在于让大家知道一种简单建造音乐播放器的方法,主要是通过Visual stdio进行。
文章包含了对音乐播放器界面实现的方法和对后台代码的理解及掌握,主要实现通过电脑使用播放器进行音乐播放功能和简单的在线搜索的功能。
通过实践进一步理解播放器的需求,以及其开发过程,根本满足群众播放器的要求。
文中使用面向.net frame框架,设计了一个简单的音乐播放器。
该播放器可以实现播放功能、搜索功能、歌词显示等。
关键字:音乐播放器、Visual studio 2021、.net frameAbstractWith the rapid development of modern economy and the continuous development of science and technology, computer information technology is becoming more and more prosperous. Music as a common way of entertainment in people's lives, but also because of the popularity of computers has changed. With digital music, media players also progress to higher quality direction. Because of the Windows Media Player’s powerful audio decoding, the most common Windows Media Player loved by everyone. If you want to make a simple music player to play songs and to experience the fun of programming,you can use the Visual stdio2021.The purpose of this is to make everyone know a simple way to build a music player, and this method is mainly achieved by the Visual stdio. Article contains the method of a music player interface implementations, to understand and grasp the code-behind, the main function of the music player is to play songs and to search online. Through practice we can further understand the needs of the player and its development process. The music player meets the requirements of the public players basically. This article uses .net framework to design a simple music player. This music player can play songs, search online, and display the lyrics.K eyword s:music player. the visual stdio 2021. .net frame目录1. 引言 (1)1.1 选题背景及意义 (1)1.2 网络流行音乐播放器简介 (1)1.2.1 酷狗音乐 (1)1.2.2 百度音乐 (2)1.3 课题研究思路 (2)2. 开发技术简介 (2)2.1 C#编程语言介绍 (2)2.2 Windows Media Player (3)2.3 Windows控件 (3)2.4 WebBrowser控件 (3)3. 需求分析 (4)3.1 功能需求 (4)开发与运行环境 (6)3.3 可行性分析 (6)3.3.1 技术可行性 (7)3.3.2 经济可行性 (7)3.3.3 法律可行性 (7)4. 系统设计 (7)设计概要 (7)4.2 功能模块 (8)5. 功能实现 (9)5.1 播放器框架设计 (9)命名空间结构 (9) (9)5.2 歌曲添加模块 (10)5.3 歌曲删除模块 (11)5.4 播放控制模块 (12)5.4.1 取消自动播放 (12)5.4.2 点击播放音乐 (12)歌曲切换 (13)5.5 自动播放下一曲 (13)5.6 显示歌词模块 (14)5.7 显示皮肤模块 (15)5.8 播放器背景模块 (16)5.9 网络连接模块 (16)6. 软件测试 (16)7. 结束语 (24)致谢 (25)参考文献 (26)基于C#实现音乐播放器功能1. 引言1.1 选题背景及意义什么是音乐?是跳动的音符跃然在琴键上,敲击出的空灵;是平稳的音律轻晃在琴弦上,弹奏出的悠闲。
C#音乐播放器设计一、音乐播放器的最终效果1. 整个播放器的主体最终效果如下:2. 经典模式如下:3. 音乐播放器设计已实现的基本功能:播放、暂停、播放列表、打开音乐文件、删除歌曲、添加歌曲、下一首、上一首、播放模式(顺序、循环、单曲循环、随机)、窗体最顶、经典模式、音量调节、歌曲播放进度控制、歌词同步、保存上次播放状态等等。
二、设计全部源代码1.主窗体(Form1)代码如下:using System;using System.Collections.Generic; using ponentModel; using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms; using System.Drawing.Imaging; using System.IO;namespace MusicPlayer{public partial class MMP : Form{public MMP(){InitializeComponent();}public int controlplay =-1;public Bitmap mplaycontrol = new Bitmap(@"play.bmp");public Bitmap mpausecontrol = new Bitmap(@"pause.bmp");public Bitmap mopenfile = new Bitmap(@"open.bmp");public Bitmap mprevious = new Bitmap(@"prev.bmp");public Bitmap mnext = new Bitmap(@"next.bmp");public Bitmap mstop = new Bitmap(@"stop.bmp");public Bitmap mmenu = new Bitmap(@"playlist_toolbar.bmp");public Boolean playcondition = false;public int preplaynum=0;Boolean p = false;Boolean fp = false;int x1, y1;Boolean yincan = false;Boolean mosttop = false;string ispaly;public int geci = 0;private void play_MouseMove(object sender, MouseEventArgs e){if (playcondition == false){Rectangle theRectangle = new Rectangle(new Point(113, 0), new Size(113, 48));play.Image = mplaycontrol.Clone(theRectangle, PixelFormat.DontCare);}else{Rectangle theRectangle = new Rectangle(new Point(113, 0), new Size(113, 48));play.Image = mpausecontrol.Clone(theRectangle, PixelFormat.DontCare);}}private void play_MouseLeave(object sender, EventArgs e){if (playcondition == false){Rectangle theRectangle = new Rectangle(new Point(0, 0), new Size(113, 48));play.Image = mplaycontrol.Clone(theRectangle, PixelFormat.DontCare);}else{Rectangle theRectangle = new Rectangle(new Point(0, 0), new Size(113, 48));play.Image = mpausecontrol.Clone(theRectangle, PixelFormat.DontCare);}}private void openfile_MouseMove(object sender, MouseEventArgs e){Rectangle theRectangle = new Rectangle(new Point(60, 0), newSize(60, 48));openfile.Image = mopenfile.Clone(theRectangle,PixelFormat.DontCare);}private void openfile_MouseLeave(object sender, EventArgs e){Rectangle theRectangle = new Rectangle(new Point(0, 0), new Size(60, 48));openfile.Image = mopenfile.Clone(theRectangle,PixelFormat.DontCare);}private void previous_MouseLeave(object sender, EventArgs e){Rectangle theRectangle = new Rectangle(new Point(0, 0), new Size(83, 48));previous.Image = mprevious.Clone(theRectangle,PixelFormat.DontCare);}private void next_MouseMove(object sender, MouseEventArgs e){Rectangle theRectangle = new Rectangle(new Point(83, 0), newSize(83, 48));next.Image = mnext.Clone(theRectangle, PixelFormat.DontCare);}private void next_MouseLeave(object sender, EventArgs e){Rectangle theRectangle = new Rectangle(new Point(0, 0), new Size(83, 48));next.Image = mnext.Clone(theRectangle, PixelFormat.DontCare);}private void stop_MouseMove(object sender, MouseEventArgs e){Rectangle theRectangle = new Rectangle(new Point(60, 0), newSize(60, 48));stop.Image = mstop.Clone(theRectangle, PixelFormat.DontCare);}private void previous_MouseMove(object sender, MouseEventArgs e){Rectangle theRectangle = new Rectangle(new Point(83, 0), newSize(83, 48));previous.Image = mprevious.Clone(theRectangle,PixelFormat.DontCare);}private void stop_MouseLeave(object sender, EventArgs e){Rectangle theRectangle = new Rectangle(new Point(0, 0), new Size(60, 48));stop.Image = mstop.Clone(theRectangle, PixelFormat.DontCare);}private void play_Click(object sender, EventArgs e){}private void play_MouseDown(object sender, MouseEventArgs e){if (playcondition == false && playlist.Items .Count !=0){playcondition = true;musicplayer.Ctlcontrols.play();}else{playcondition = false;}}private void openfile_MouseDown(object sender, MouseEventArgs e){Rectangle theRectangle = new Rectangle(new Point(120, 0), new Size(60, 48));openfile.Image = mopenfile.Clone(theRectangle,PixelFormat.DontCare);}private void previous_MouseDown(object sender, MouseEventArgs e){if (playlist.Items.Count != 0){Rectangle theRectangle = new Rectangle(new Point(166, 0), new Size(83, 48));previous.Image = mprevious.Clone(theRectangle, PixelFormat.DontCare);musicplayer.Ctlcontrols.previous();if (preplaynum > 0){preplaynum = preplaynum - 1;playlist.SelectedIndex = preplaynum;}else{preplaynum = playlist.Items.Count - 1;playlist.SelectedIndex = preplaynum;}musicplayer.Ctlcontrols.playItem(musicplayer.currentPlaylist.Item[preplaynum]);preplaynum = playlist.SelectedIndex;}}private void next_MouseDown(object sender, MouseEventArgs e){if (playlist.Items.Count != 0){Rectangle theRectangle = new Rectangle(new Point(166, 0), new Size(83, 48));next.Image = mnext.Clone(theRectangle, PixelFormat.DontCare);if (preplaynum < playlist.Items.Count - 1){preplaynum = preplaynum + 1;playlist.SelectedIndex = preplaynum;}else{preplaynum = 0;playlist.SelectedIndex =0;}musicplayer.Ctlcontrols.playItem(musicplayer.currentPlaylist.Item[preplaynum]);}}private void stop_MouseDown(object sender, MouseEventArgs e){Rectangle theRectangle = new Rectangle(new Point(120, 0), new Size(60, 48));stop.Image = mstop.Clone(theRectangle, PixelFormat.DontCare);Rectangle Rectangle = new Rectangle(new Point(0, 0), new Size(113, 48));play.Image = mplaycontrol.Clone(Rectangle, PixelFormat.DontCare);playcondition = false;musicplayer.Ctlcontrols.stop();}private void openfile_Click(object sender, EventArgs e){openmusic.Multiselect = true;string musicname;string[] filepath;openmusic.Title = "打开音乐文件";openmusic .InitialDirectory="D:\\";openmusic.Filter = "mp3|*.mp3|wma|*.wma";openmusic.ShowDialog();filepath = openmusic.FileNames;int num = filepath.Length;for (int k = 0; k < num; k++){if (filepath[k] != ""){musicplayer.currentPlaylist.insertItem(musicplayer.currentPlaylist.count, musicplayer.newMedia(filepath[k]));musicname =musicplayer.currentPlaylist.Item[musicplayer.currentPlaylist.count - 1].name;int n = 0;for (int i = 0; i < playlist.Items.Count; i++){if (musicplayer.currentPlaylist.Item[i].name == musicname){n = 1;musicplayer.Ctlcontrols.playItem(musicplayer.currentPlaylist.Item[i]);preplaynum = i;playlist.SelectedIndex = i;i = playlist.Items.Count;}}if (n == 0){playlist.Items.Add((playlist.Items.Count + 1) + "." + musicname);musicplayer.Ctlcontrols.playItem(musicplayer.currentPlaylist.Item[musicplayer.curre ntPlaylist.count - 1]);playlist.SelectedIndex =playlist .Items .Count -1;preplaynum = preplaynum + 1;}else{musicplayer.currentPlaylist.removeItem(musicplayer.currentPlaylist.Item[musicplayer .currentPlaylist.count - 1]);}}}}private void listBox1_SelectedIndexChanged(object sender, EventArgs e){}private void playlist_SelectedIndexChanged(object sender, EventArgs e){}private void playlist_DoubleClick(object sender, EventArgs e){preplaynum = playlist.SelectedIndex;musicplayer.Ctlcontrols.playItem(musicplayer.currentPlaylist.Item[playlist.SelectedIn dex]);}private void timer1_Tick(object sender, EventArgs e){if (musicplayer.currentPlaylist.count != 0) miname.Text = ;playtime.Text = "00:00";if (musicplayer.Ctlcontrols.currentPositionString != ""){playtime.Text = musicplayer.Ctlcontrols.currentPositionString;progressbar1.Width = Convert.ToInt16(progressbar.Width * musicplayer.Ctlcontrols.currentPosition / musicplayer.currentMedia.duration);progressbar1.Visible = true;}else{progressbar1.Visible = false;}}private void musicplayer_MediaCollectionAttributeStringChanged(object sender,AxWMPLib._WMPOCXEvents_MediaCollectionAttributeStringChangedEvent e) {}private void musicplayer_OpenStateChange(object sender,AxWMPLib._WMPOCXEvents_OpenStateChangeEvent e){Rectangle theRectangle = new Rectangle(new Point(0, 0), new Size(113, 48));play.Image = mpausecontrol.Clone(theRectangle, PixelFormat.DontCare);playcondition = true;alltime.Text = musicplayer.currentMedia.durationString;}private void secondface_Click(object sender, EventArgs e){}private void musicplayer_Enter(object sender, EventArgs e){}private void MMP_Load(object sender, EventArgs e){this.Icon = notifyIcon1.Icon;panel1.BackColor = Color.Transparent;//不存在时创建文件,存在时追加文件StreamWriter sp = new StreamWriter("musicpath.txt", true, Encoding.UTF8);StreamWriter sn = new StreamWriter("musicname.txt", true, Encoding.UTF8);StreamWriter s = new StreamWriter("saveset.txt", true, Encoding.UTF8);sp.Close();sn.Close();s.Close();//打开文件,读取数据StreamReader swp = File.OpenText("musicpath.txt");StreamReader swn = File.OpenText("musicname.txt");StreamReader sw = File.OpenText("saveset.txt");string pathline;string nameline;string saveline;while ((pathline = swp.ReadLine()) != null&&(nameline =swn.ReadLine()) != null){if (File.Exists(pathline)){musicplayer.currentPlaylist.insertItem(musicplayer.currentPlaylist.count, musicplayer.newMedia(pathline));playlist.Items.Add(nameline);}}swn.Close();swp.Close();if (playlist.Items.Count < 1) miname.Text = "无任何曲目";int i=0;int r=192, g=192, b=0;//string[] save;//saveline = sw.ReadToEnd();//save=saveline.Split(' ');//MessageBox.Show(save[1].ToString ());while ((saveline = sw.ReadLine()) != null){switch (i){case 0:if (playlist.Items.Count > 0 && playlist.Items.Count > Convert.ToInt16(saveline))musicplayer.Ctlcontrols.playItem(musicplayer.currentPlaylist.Item[Convert.ToInt16(s aveline)]);elsemusicplayer.Ctlcontrols.playItem(musicplayer.currentPlaylist.Item[0]);break ;case 1:ispaly = saveline;break ;case 2:r= Convert.ToInt32 (saveline );break;case 3:g = Convert.ToInt32(saveline);break;case 4:b = Convert.ToInt32(saveline);break;}i++;}sw.Close();playlist.BackColor = Color.FromArgb(r, g, b);addmusic.Image = mmenu.Clone(new Rectangle(new Point(0, 0), new Size(38, 26)), PixelFormat.DontCare);clearmusic.Image = mmenu.Clone(new Rectangle(new Point(38, 0), new Size(38, 26)), PixelFormat.DontCare);findmusic.Image = mmenu.Clone(new Rectangle(new Point(152, 0), new Size(38, 26)), PixelFormat.DontCare);hidelist.Image = mmenu.Clone(new Rectangle(new Point(76, 0), new Size(38, 26)), PixelFormat.DontCare);musicitem.Image = mmenu.Clone(new Rectangle(new Point(190, 0), new Size(38, 26)), PixelFormat.DontCare);playstyle.Image = mmenu.Clone(new Rectangle(new Point(228, 0), new Size(38, 26)), PixelFormat.DontCare);alltime.BackColor = Color.Transparent;progressbar1.Width = progressbar.Width;progressbar1.Height = progressbar.Height ;progressbar1.Left = progressbar.Left ;progressbar1.Top = progressbar.Top;allloop.Checked = true;oneloop.Checked = false;orderloop.Checked = false;randloop.Checked = false;timer3.Enabled = false;musicplayer.settings.setMode("loop", true);top.Image = new Bitmap(@"toph.jpg");voice.Value = 50;}private void progressbar_MouseDown(object sender, MouseEventArgs e){if (playtime.Text != "" && e.X!=0&&playlist .Items .Count !=0){progressbar1.Width = Convert.ToInt16(e.X);musicplayer.Ctlcontrols.currentPosition =musicplayer.currentMedia.duration * e.X / progressbar.Width;}}private void progressbar1_MouseDown(object sender, MouseEventArgs e){if (playtime.Text != "" && e.X != 0 && playlist.Items.Count != 0){progressbar1.Width = Convert.ToInt16(e.X);musicplayer.Ctlcontrols.currentPosition =musicplayer.currentMedia.duration * e.X / progressbar.Width;}}private void musicplayer_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e){}private void openmusic_FileOk(object sender, CancelEventArgs e){}private void next_Click(object sender, EventArgs e){}private void musicplayer_PlaylistChange(object sender,AxWMPLib._WMPOCXEvents_PlaylistChangeEvent e){}private void miname_TextChanged(object sender, EventArgs e){if (ispaly == "False"){musicplayer.Ctlcontrols.pause();Rectangle theRectangle = new Rectangle(new Point(0, 0), new Size(113, 48));play.Image = mplaycontrol.Clone(theRectangle, PixelFormat.DontCare);playcondition = false;ispaly = "True";}int index;string music;for (int i =0; i < playlist.Items.Count; i++){music = playlist.Items[i].ToString();index = music.IndexOf('.');if (music.Substring(index + 1, music.Length - 1 - index) == miname.Text){preplaynum = i;playlist.SelectedIndex =i;}}//}private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e){}private void minsize_Click(object sender, EventArgs e){this.WindowState =System.Windows.Forms.FormWindowState.Minimized;}private void exit_Click(object sender, EventArgs e){FileInfo musicpath = new FileInfo("musicpath.txt");FileInfo musicname = new FileInfo("musicname.txt");FileInfo saveset = new FileInfo("saveset.txt");StreamWriter swp =musicpath.CreateText();StreamWriter swn=musicname .CreateText();StreamWriter sw = saveset.CreateText();for (int i = 0; i < playlist.Items.Count; i++){swp.WriteLine(musicplayer .currentPlaylist .Item[i].sourceURL );swn.WriteLine(playlist.Items[i].ToString());}sw.WriteLine(preplaynum);sw.WriteLine(playcondition);sw.WriteLine(playlist.BackColor.R);sw.WriteLine(playlist.BackColor.G);sw.WriteLine(playlist.BackColor.B);swn.Close();swp.Close();sw.Close();Application.Exit();}private void toolStripMenuItem1_Click(object sender, EventArgs e){}private void toolStripMenuItem2_Click(object sender, EventArgs e){}private void panel1_Click(object sender, EventArgs e){addmusic.Visible = true;}private void toolStripMenuItem1_Click_1(object sender, EventArgs e){int n = playlist.SelectedIndex;if (n> -1){musicplayer.currentPlaylist.removeItem(musicplayer.currentPlaylist.Item[n]);}playlist.Items.Clear();for (int i = 0; i < musicplayer .currentPlaylist .count; i++){playlist.Items.Add ((i+1)+"."+musicplayer.currentPlaylist .Item [i].name );}if (playlist.Items.Count - 1 >= n){playlist.SelectedItem = playlist.Items[n];}else{playlist.SelectedItem = playlist.Items[n - 1];}}private void clearall_Click(object sender, EventArgs e){playlist.Items.Clear();musicplayer.currentPlaylist.clear();miname.Text = "无任何曲目";}private void orderloop_Click(object sender, EventArgs e){allloop.Checked =false ;oneloop.Checked = false;orderloop.Checked = true ;randloop.Checked = false;timer3.Enabled = false;musicplayer.settings.setMode("shuffle", false);}private void randloop_Click(object sender, EventArgs e){allloop.Checked = false ;oneloop.Checked = false;orderloop.Checked = false;randloop.Checked = true ;timer3.Enabled = false;musicplayer.settings.setMode("shuffle",true );}private void allloop_Click(object sender, EventArgs e){allloop.Checked =true ;oneloop.Checked = false;orderloop.Checked = false;randloop.Checked = false;timer3.Enabled = false ;musicplayer.settings.setMode("loop",true );}private void oneloop_Click(object sender, EventArgs e){allloop.Checked = false ;oneloop.Checked = true ;orderloop.Checked = false;randloop.Checked = false;timer3.Enabled = true;}private void mainface_Click(object sender, EventArgs e){}private void hidelist_Click(object sender, EventArgs e){if (yincan == false){this.Height = 255;yincan = true;}else{this.Height = 494;yincan = false;}}private void playlist_MouseDown(object sender, MouseEventArgs e) {}private void playlist_MouseMove(object sender, MouseEventArgs e) {private void playlist_MouseUp(object sender, MouseEventArgs e){}private void secondface_MouseMove(object sender, MouseEventArgs e) {if (e.X > playlist.Width + 1 && e.X < playlist.Width + 10){secondface.Cursor = System.Windows.Forms.Cursors.SizeWE;}elsesecondface.Cursor = System.Windows.Forms.Cursors.Default;if (p == true && e.X > 200 && e.X < 385){playlist.Width = e.X;}}private void secondface_MouseDown(object sender, MouseEventArgs e) {if (e.X > playlist.Width-5 && e.X < playlist.Width + 10){secondface.Cursor = System.Windows.Forms.Cursors.SizeWE;p = true;}}private void secondface_MouseUp(object sender, MouseEventArgs e) {secondface.Cursor = System.Windows.Forms.Cursors.Default;p = false;}private void MMP_MouseDown(object sender, MouseEventArgs e) {if (e.Y < 30){x1 = e.X;y1 = e.Y;fp = true;}private void MMP_MouseMove(object sender, MouseEventArgs e) {if (fp == true){this.Left = this.Left + e.X - x1;this.Top = this.Top + e.Y - y1;}}private void MMP_MouseUp(object sender, MouseEventArgs e){fp = false;}private void mainface_MouseDown(object sender, MouseEventArgs e) {if (e.Y < 30){x1 = e.X;y1 = e.Y;fp = true;}}private void mainface_MouseMove(object sender, MouseEventArgs e) {if (fp == true){this.Left = this.Left + e.X - x1;this.Top = this.Top + e.Y - y1;}}private void mainface_MouseUp(object sender, MouseEventArgs e) {fp = false;}private void hScrollBar1_Scroll(object sender, ScrollEventArgs e) {musicplayer.settings.volume = voice.Value;toolTip1.SetToolTip(voice, "音量" + voice.Value + "%");if (voice.Value == 0) toolTip1.SetToolTip(voice, "静音");}private void button1_Click(object sender, EventArgs e){}private void voice_Move(object sender, EventArgs e){}private void voice_MouseEnter(object sender, EventArgs e){voice.Cursor = System.Windows.Forms.Cursors.Hand;}private void voice_MouseHover(object sender, EventArgs e){toolTip1.SetToolTip(voice, "音量" + voice.Value + "%");if (voice.Value == 0) toolTip1.SetToolTip(voice, "静音");}private void progressbar_MouseMove(object sender, MouseEventArgs e) {}private void progressbar_MouseEnter(object sender, EventArgs e){toolTip1.SetToolTip(progressbar, "进度控制");progressbar.Cursor = System.Windows.Forms.Cursors.Hand;}private void play_MouseEnter(object sender, EventArgs e){play.Cursor = System.Windows.Forms.Cursors.Hand;if(playcondition ==false)toolTip1.SetToolTip(play , "播放");elsetoolTip1.SetToolTip(play, "暂停");}private void next_MouseEnter(object sender, EventArgs e){next.Cursor = System.Windows.Forms.Cursors.Hand;toolTip1.SetToolTip(next , "下一首");}private void stop_MouseEnter(object sender, EventArgs e){stop.Cursor = System.Windows.Forms.Cursors.Hand;toolTip1.SetToolTip(stop , "停止");}private void previous_MouseEnter(object sender, EventArgs e){previous.Cursor = System.Windows.Forms.Cursors.Hand;toolTip1.SetToolTip(previous , "上一首");}private void openfile_MouseEnter(object sender, EventArgs e){openfile.Cursor = System.Windows.Forms.Cursors.Hand;toolTip1.SetToolTip(openfile , "打开文件");}private void playstyle_MouseEnter(object sender, EventArgs e){}private void menuStrip1_MouseEnter(object sender, EventArgs e){menuStrip1.Cursor = System.Windows.Forms.Cursors.Hand;}private void menuStrip1_MouseMove(object sender, MouseEventArgs e) {}private void progressbar1_MouseEnter(object sender, EventArgs e){progressbar1.Cursor = System.Windows.Forms.Cursors.Hand;}private void button1_Click_1(object sender, EventArgs e){}private void changeface_Click(object sender, EventArgs e){}private void changcolor_Click(object sender, EventArgs e){colorDialog1.ShowDialog();playlist.BackColor = colorDialog1.Color;}private void pictureBox2_Click(object sender, EventArgs e){}private void notifyIcon1_Click(object sender, EventArgs e){this.WindowState =System.Windows.Forms.FormWindowState.Normal;}private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e){}private void minsize_MouseEnter(object sender, EventArgs e){toolTip1.SetToolTip(minsize, "最小化");}private void exit_MouseEnter(object sender, EventArgs e)toolTip1.SetToolTip(exit, "关闭");}private void top_MouseEnter(object sender, EventArgs e){if (this.TopMost ==false )toolTip1.SetToolTip(top , "置顶");elsetoolTip1.SetToolTip(top , "取消置顶");}private void top_MouseDown(object sender, MouseEventArgs e) {if (mosttop == false){mosttop = true;top.Image = new Bitmap(@"toph.jpg");this.TopMost = false;}else{mosttop = false;top.Image = new Bitmap(@"topz.jpg");this.TopMost = true;}}private void miname_Click(object sender, EventArgs e){}private void button1_Click_2(object sender, EventArgs e){progressbar1.BackColor = Color.FromArgb(20, 34, 120); }private void button1_Click_3(object sender, EventArgs e){}private void timer2_Tick(object sender, EventArgs e)if (controlplay == 1){playcondition = true;musicplayer.Ctlcontrols.play();controlplay = -1;}if (controlplay == 0){playcondition = false;musicplayer.Ctlcontrols.pause();controlplay = -1;}}private void button2_Click(object sender, EventArgs e){}private void pictureBox1_Click(object sender, EventArgs e){this.Hide();miniplayer secondform;secondform = new miniplayer(this );secondform.Show();}private void pictureBox1_MouseEnter(object sender, EventArgs e){toolTip1.SetToolTip(newstyle, "经典模式");}private void previous_Click(object sender, EventArgs e){}private void timer3_Tick(object sender, EventArgs e){if (musicplayer.Ctlcontrols.currentPosition >musicplayer.currentMedia.duration - 0.5)musicplayer.Ctlcontrols.playItem(musicplayer.currentPlaylist.Item[preplaynum]);private void button1_Click_4(object sender, EventArgs e){if (geci == 0){Form3 f3 = new Form3(this);f3.Show();geci = 1;}}private void button1_MouseEnter(object sender, EventArgs e){toolTip1.SetToolTip(button1, "显示歌词");}private void progressbar_Click(object sender, EventArgs e){}}}2.经典模式窗体(From2)代码如下:using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Drawing.Imaging;namespace MusicPlayer{public partial class miniplayer : Form{private MMP mainform;public miniplayer(MMP f){InitializeComponent();mainform = f;}Bitmap play_bmp = new Bitmap("play (2).bmp");Bitmap pause_bmp = new Bitmap("pause (2).bmp");Bitmap next_bmp = new Bitmap("next (2).bmp");Bitmap previous_bmp = new Bitmap("prev (2).bmp");Boolean a = false;int x1, y1;private void miniplayer_Load(object sender, EventArgs e){ //on.Left = under.Left;on.Top = under.Top;on.Width = under.Width;on.Height = under.Height;//if (mainform.TopMost == true) this.TopMost = true;if (mainform.playcondition == false)playbutton.Image = play_bmp.Clone(new Rectangle(new Point(0, 0), new Size(23, 17)), PixelFormat.DontCare);elseplaybutton.Image = pause_bmp.Clone(new Rectangle(new Point(0, 0), new Size(23, 17)), PixelFormat.DontCare);previousbutton.Image = previous_bmp.Clone(new Rectangle(new Point(0, 0), new Size(23, 17)), PixelFormat.DontCare);nextbutton.Image =next_bmp.Clone(new Rectangle(new Point(0, 0), new Size(23, 17)), PixelFormat.DontCare);}private void nextbutton_Click(object sender, EventArgs e){playbutton.Image = pause_bmp.Clone(new Rectangle(new Point(23, 0), new Size(23, 17)), PixelFormat.DontCare);}private void nextbutton_MouseEnter(object sender, EventArgs e){nextbutton.Image = next_bmp.Clone(new Rectangle(new Point(23, 0), new Size(23, 17)), PixelFormat.DontCare);}private void nextbutton_MouseLeave(object sender, EventArgs e){nextbutton.Image = next_bmp.Clone(new Rectangle(new Point(0, 0), new Size(23, 17)), PixelFormat.DontCare);}private void nextbutton_MouseUp(object sender, MouseEventArgs e){nextbutton.Image = next_bmp.Clone(new Rectangle(new Point(23, 0), new Size(23, 17)), PixelFormat.DontCare);}private void nextbutton_MouseDown(object sender, MouseEventArgs e){//if (mainform.playlist.Items.Count != 0){mainform.musicplayer.Ctlcontrols.next();if (mainform.preplaynum < mainform.playlist.Items.Count - 1){mainform.preplaynum = mainform.preplaynum + 1;mainform.playlist.SelectedItem =mainform.playlist.Items[mainform.preplaynum];}else{mainform.preplaynum = 0;mainform.playlist.SelectedItem =mainform.playlist.Items[0];}mainform.musicplayer.Ctlcontrols.playItem(mainform.musicplayer.currentPlaylist.Ite m[mainform.preplaynum]);}//nextbutton.Image = next_bmp.Clone(new Rectangle(new Point(46, 0), new Size(23, 17)), PixelFormat.DontCare);}private void previousbutton_MouseLeave(object sender, EventArgs e){previousbutton.Image = previous_bmp.Clone(new Rectangle(new Point(0, 0), new Size(23, 17)), PixelFormat.DontCare);}private void previousbutton_MouseEnter(object sender, EventArgs e){previousbutton.Image = previous_bmp.Clone(new Rectangle(new Point(23, 0), new Size(23, 17)), PixelFormat.DontCare);}private void previousbutton_MouseDown(object sender, MouseEventArgs e){//if (mainform.playlist.Items.Count != 0){mainform.musicplayer.Ctlcontrols.previous();if (mainform.preplaynum > 0){mainform.preplaynum = mainform.preplaynum - 1;mainform.playlist.SelectedItem =mainform.playlist.Items[mainform.preplaynum];}else{mainform.preplaynum = mainform.playlist.Items.Count - 1;mainform.playlist.SelectedItem =mainform.playlist.Items[mainform.preplaynum];}mainform.musicplayer.Ctlcontrols.playItem(mainform.musicplayer.currentPlaylist.Ite m[mainform.preplaynum]);。
VC++编写视频音乐播放器Softeem Consultancy ServiceVC++编写视频音乐播放器Softeem Consultancy Service音乐播放器程序主要功能音乐播放器可以播放Windows下常用的音频和视频文件,如MP3、MIDI、WAV、WMA等。
程序的界面如图所示。
用户可通过文件对话框添加想要播放的文件和删除音乐文件,并可实现暂停、关闭或重播的功能,保存播放列表,并显示播放的时间和正在播放文件的全路径和文件名,同时,在媒体文件播放的过程中,用户可随时调节音量,还可以设置播放模式,如单曲循环,顺序播放等,同时,可以同步歌词,同步视频,并在桌面显示等。
Softeem Consultancy Service程序界面Softeem Consultancy Service运行效果Softeem Consultancy Service创建初始界面程序实现界面美化1,首先新建一个工程,取个好听的名字,这里命名为Multimedia,然后选择Dialog based,点击OK完成。
2,设置对话框显示风格。
在对话框点右键属性,设置边框为细小,把标题栏复选框去掉,其他默认。
如图:Softeem Consultancy Service3,界面布局。
在对话框中添加相应的控件,完成相应功能,最终效果如图:Softeem Consultancy Service4.进行对话框、控件的相应美化。
(1)给对话框添加背景 (2)给按钮添加位图(3)使静态文本透明 (4) 相关控件的具体美化实现播放音乐Windows MCI与多媒体软件开发 Windows MCI(Media Control Interface)是控制多媒体设备的高层命令接口,提供了与设备无关的控制多媒体设备的方法。
MCI可控制的多媒体设备包括标准的多媒体设备,如CD音频(CD Audio)、数字视频、动画、Wave格式数字声音和MIDI音序器,以及影碟机等可选设备。
控制台C语言编写音乐播放器主要功能音乐播放器是一种可以播放音乐文件的应用程序,具有多种功能来帮助用户管理和播放音乐。
下面是控制台C语言编写音乐播放器的主要功能:1.音乐:用户可以通过输入歌曲名或艺术家来他们想要播放的音乐。
功能也可以根据关键词进行过滤和排序。
2.音乐播放:一旦用户找到他们想要听的歌曲,他们可以选择播放它。
音乐播放器应该能够打开并解码音乐文件,然后通过音频设备播放音乐。
4.歌曲信息显示:在播放音乐的同时,音乐播放器应该显示歌曲的相关信息,如歌曲名、艺术家、专辑名、歌词等。
这些信息可以从音乐文件的元数据中获取。
5.音乐控制:音乐播放器应该具有基本的音乐控制功能,如播放、暂停、停止、上一首、下一首等。
用户可以通过命令来控制音乐的播放状态。
6.音量控制:用户可以通过增加或减少音量来调整音乐的音量。
音乐播放器应该能够调整音频设备的输出音量。
7.重复和随机播放:用户可以选择歌曲的播放模式,如顺序播放、循环播放、随机播放等。
音乐播放器应该能够根据用户的选择来调整播放模式。
9.用户界面:音乐播放器应该有一个简洁而直观的用户界面,允许用户轻松地浏览、和管理自己的音乐。
用户界面可以使用控制台界面或基于文本的界面。
10.错误处理:音乐播放器应该能够处理各种错误情况,如无效的输入、文件不存在、解码错误等。
它应该能够向用户显示有关错误的信息,并采取适当的措施来避免应用程序崩溃。
11.文件格式支持:音乐播放器应该支持多种常见的音乐文件格式,如MP3、WAV、FLAC等。
它应该能够根据文件格式选择合适的解码器。
12.常规设置:音乐播放器应该具有一些常规设置,如默认音量、默认播放模式、快捷键等。
用户可以根据自己的需求来调整这些设置。
以上是控制台C语言编写音乐播放器的主要功能。
根据以上功能,你可以开始设计和编写一个简单的音乐播放器应用程序。
当然,你可以根据个人需求和编程能力来扩展和优化这些功能。
一、软件说明:功能说明:一个简易小巧的MP3播放器,可以播放已经下载好的MP3格式的音乐。
解决什么样的实际问题:市场上的音乐播放器大都占用资源比较大,而且需要联网,即使播放本地音乐,也会占用较多的网速,而这款播放器解决了这些问题。
(虽然还是有很多缺陷,但用起来还是比较方便的。
)性能说明:可以播放单首或多首歌曲,可以保存或清空当前播放列表,支持列表循环,顺序播放,单曲循环。
(但目前只支持MP3格式。
)程序类型说明:这个播放器是winform应用程序。
二、软件设计软件整体结构图及模块划分:软件整体结构图:控制模块:歌曲列表显示区:在VS的“解决方案资源管理器”中的文件说明:整个项目的文件如下:其中,Properties中所包含的的文件有:这里包含的是定义程序集属性的文件,用来设定生成的有关程序集的常规信息dll文件的一些参数。
引用中包含的文件有:这里包含的是这个项目所用的的一些类库信息。
Form1.cs中包含有:这些是窗体的设计信息,而Program.cs是整个源程序的入口。
各模块对应的主要对象或方法:控制模块中主要用到的是axWindowsmediaPlayer控件以及MenuStrip控件。
其中Windows media Player 控件用到的方法属性主要有:axWindowsMediaPlayer1.BeginInit(); //初始化axWindowsMediaPlayer1.settings.autoStart; //自动播放axWindowsMediaPlayer1.settings.setMode("shuffle", false); //顺序播放axWindowsMediaPlayer1.settings.enableErrorDialogs;axWindowsMediaPlayer1.settings.balance;axWindowsMediaPlayer1.settings.mute;axWindowsMediaPlayer1.settings.volume;MenuStrip控件用到的方法事件有:privatevoid打开文件ToolStripMenuItem1_Click(object sender, EventArgs e);privatevoid添加歌曲ToolStripMenuItem_Click(object sender, EventArgs e);privatevoid添加文件夹ToolStripMenuItem_Click(object sender, EventArgs e);privatevoid退出ToolStripMenuItem_Click(object sender, EventArgs e); privatevoid清空列表ToolStripMenuItem1_Click(object sender, EventArgs e);privatevoid顺序播放ToolStripMenuItem_Click(object sender, EventArgs e);privatevoid单曲循环ToolStripMenuItem_Click(object sender, EventArgs e);privatevoid随机播放ToolStripMenuItem_Click(object sender, EventArgs e);数据库设计或数据文件说明:由于播放器使用数据量较小,故采用TXT保存歌曲文件列表。
Mp3 音乐播放器设计文档一、需求:名称:mp3音乐播放器目的:随时随地播放音乐、动画,查看文本文件输入:一个电源开关,一个确定按钮,上、下按钮,USB接口输出:液晶显示屏,耳机功能:可以从PC上下载各种电脑文件,具有移动存储的功能;能够识别并播放音乐文件,同步显示歌词,可以调节音效;显示.txt文本文件;性能:按钮刚按下即可刷新屏幕,所有操作在0.5秒内执行完毕生产成本:低于100元功耗:200mW物理尺寸和重量:体积不大于5cm*3cm*1cm;重量轻于100g二、规格说明1、概要规格说明系统的功能至少包括:接收从PC上下载的各类电脑文件并长久保存;执行用户选择的操作;列举所有音频文件,根据用户的选择播放任何一个文件,如有歌词则显示歌词;列举所有文本文件,根据用户选择显示任何一个;用例图:加电后的MP3执行过程:操作系统加载完成后,处于监听状态,在用户选择完需要完成的动作后,由操作系统调用相关对象的方法来实现其功能。
2、详细规格说明:所有的类及其成员变量、方法都归在类图之中Translate类:将数据转化成可以在LCD屏幕上显示的格式;Panel类:管理在屏幕上显示的各个选项,可以高亮表示选择,需要保存所有显示的item;FileSystem类:管理mp3中的所有可以识别的文件,可以读取、添加和删除文件;File类:抽象类,各个文件类型必须继承该类;Music类:表示音频文件类型,可以控制音频文件的播放、暂停、停止;TextFile类:表示文本文件类型,可以显示文本文件;Lyric类表示与音乐相关的歌词文件;Voice类:管理音乐的声音大小、播放模式(如摇滚、古典、流行等)ChangeSignal类:将音频文件转变成模拟信号,传输给耳机等外设。
当用户指定执行某种功能的时候,由操作系统来调用各个类的相关方法。
以下为某次用户要求播放某个音乐文件的顺序图:系统从FileSystem对象中获取文件,在Panel对象中显示出来,用户选择需要播放的音乐文件后,由Music对象播放;同时可以可以通过Voice对象调节音量;在播放结束后,Panel对象更新要显示的内容;每次更新后,都要由TranslateToLCD对象将其送到屏幕显示。
#include "FM_Main.h"#include"CTL.H"#include<stdio.h>#include<windows.h>#include<mmsystem.h>#include"GUI.h"#include"ERR_CheckEnter.h"#pragma comment(lib,"winmm.lib")#include "FM_CheckFile.c"#include"FM_Choose.c"#include"FM_List.c"#include "FM_Path.c"int Order=1; //初始时为第一首歌,随音乐切换而切换--nextsong() int NewOrder=0;int Amount = 0; //歌曲总量int begin; //自定义列表中开始序号int circulatemode=1; //循环模式int pp=0;int begintemp=0; //存储自定义列表边界int ww=-1; // 显示自定义列表当前播放信息int upordown=1; //判断切歌方向int firstup=0;int originvolume=500; //默认音量为500char v[40]="setaudio aa volume to 500"; //初始化音量void Init(){Order=1;NewOrder=0;Amount = 0;circulatemode=1;pp=0;begintemp=0;ww=-1;upordown=1;firstup=0;originvolume=500;}void ShowFileList(){if(begintemp==0)begintemp=begin;Amount = FM_CheckFile();begin = Amount;if(NewOrder==0){Show_GUI_EIGHT();FM_CheckFilePrint(0,Amount);}else{Show_GUI_EIGHT();FM_CheckFilePrint(Amount,begintemp);}};void ShowFileDetails(){int i=0;if(upordown==1){if(NewOrder!=0){Order=Amount+1+ww;ww++;}}if(upordown==2){if(firstup==0){if(NewOrder!=0){Order=Amount+1+ww;ww--;}firstup--;}else{if(NewOrder!=0){Order=Amount+1+ww;ww--;}}}firstup+=4;i=Order-1;printf(" 正在播放的音乐\n");printf(" -------------------------------------------------------\n");printf(" 歌曲号歌曲名歌手名\n");printf(" -------------------------------------------------------\n");printf(" %3d ",info[i].ID);printf(" %-20s ",info[i].song);printf(" %-10s\n",info[i].singer);printf(" -------------------------------------------------------\n");}void Play(){if(NewOrder!=0)Order=Amount+1;char vol[10]="500";char v[40];char ch[200];sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);sprintf(v," setaudio aa volume to %s",vol);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa repeat",NULL,0,NULL);// getchar();}void Stop(){mciSendString ("pause aa",NULL,0,NULL);printf("歌曲播放已暂停,输入3继续播放,输入12退出\n\n");//getchar();}void Resume(){mciSendString ("resume aa",NULL,0,NULL);//getchar();}void FastForward(){int n=1;int m=0;int d=0;int minute;int second;char dd[60][20];char temp[20];do{printf("输入1快进:");scanf("%d",&n);mciSendString ("status aa position", dd[m], 20, 0);char ch[20];sprintf(ch,"%s",dd[m]);d=atoi(dd[m]);d+=5000;minute=(int)(((int)(d/1000))/60);second=(d/1000)-minute*60;itoa(d,dd[m],10);sprintf(temp,"seek aa to %s",dd[m]);mciSendString (temp,NULL,0,NULL);Play();m++;clrscr();ShowFileList();ShowFileDetails();Show_GUI_FOUR();printf("当前时间:%d:%02d \n",minute,second);}while(n==1);}void FastBack(){int n=1;int m=0;int d=0;int minute;int second;char dd[60][20];char temp[20];do{printf("输入1快退");scanf("%d",&n);mciSendString ("status aa position", dd[m], 20, 0);char ch[20];sprintf(ch,"%s",dd[m]);d=atoi(dd[m]);d-=5000;minute=(int)(((int)(d/1000))/60);second=(d/1000)-minute*60;itoa(d,dd[m],10);sprintf(temp,"seek aa to %s",dd[m]);mciSendString (temp,NULL,0,NULL);Play();m++;clrscr();ShowFileList();ShowFileDetails();Show_GUI_FOUR();printf("当前时间:%d:%02d \n",minute,second);}while(n==1);}void StopStop(){char temp[20];char ch[10];itoa(0,ch,10);sprintf(temp,"seek aa to %s",ch);mciSendString (temp,NULL,0,NULL);mciSendString ("pause aa",NULL,0,NULL);printf("点击1重新播放\n\n");}void VolumePlus(){int n=1;//int originvolume=500;char volume[10];char temp[40];while(n==1){printf("输入1增加音量,输入2退出音量增加模式");scanf("%d",&n);originvolume+=250;itoa(originvolume,volume,10);sprintf(temp," setaudio aa volume to %s",volume);mciSendString (temp,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);getchar();clrscr();ShowFileList();ShowFileDetails();Show_GUI_FOUR();printf("当前音量:%d\n",originvolume);}originvolume-=250;}void VolumeReduce(){int n=1;//int originvolume=500;char volume[10];char temp[40];while(n==1){printf("输入1降低音量,输入2退出音量降低模式");scanf("%d",&n);originvolume-=250;itoa(originvolume,volume,10);sprintf(temp,"setaudio aa volume to %s",volume);mciSendString (temp,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);//getchar();clrscr();ShowFileList();ShowFileDetails();Show_GUI_FOUR();printf("当前音量:%d\n",originvolume);}originvolume+=250;}void PreSong(){if(NewOrder==0){if(circulatemode==1){if(Order<1){Order=1;char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);//getchar();}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);//getchar();}}if(circulatemode==2){if(Order<1){Order=Amount;char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);//getchar();}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);//getchar();}}}else{Order=Amount+pp;if(circulatemode==1){if(Order<Amount){Order=Amount;char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);//getchar();}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);//getchar();}}if(circulatemode==2){if(Order<Amount){Order=begin;char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);//getchar();}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);//getchar();}}pp--;}upordown=2;}void NextSong(){if(NewOrder==0){if(circulatemode==1){if(Order>Amount){Order=Amount;char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);//getchar();}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);//getchar();}}if(circulatemode==2){if(Order>Amount)//////////////////////////////////////////////{Order=1;char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);//getchar();}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order-1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);//getchar();}}}else{Order=Amount+pp;if(circulatemode==1){if(Order<Amount)/////////////////////有问题{Order=Amount;char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order+1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);//getchar();}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order+1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);//getchar();}}if(circulatemode==2){if(Order<Amount)//有问题{Order=begin;char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order+1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);//getchar();}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[Order+1].add);mciSendString(ch,NULL,0,NULL);mciSendString(v,NULL,0,NULL);mciSendString("play aa ",NULL,0,NULL);//getchar();}}pp++;}upordown=1;}void SelectCirculMode(){int i=0;Show_GUI_SEVEN();scanf("%d",&i);if(i==1)circulatemode=1;if(i==2)circulatemode=2;}void SaveExit(){/*char dd[20];char log[50]={"testlog"};mciSendString ("status aa position", dd, 20, 0);int d;d=atoi(dd);FILE *fp = NULL;fp = fopen("D:\\SaveLog.txt","a");fwrite(log,1,50,fp);*/}void PlayOperation(){int d;re:clrscr();ShowFileList();ShowFileDetails();Show_GUI_FOUR();printf("请选择要进行的操作:");epo:scanf("%d",&d);fflush(stdin);if(ERR_CheckEntero(d)){switch(d){case 1:Play();goto re;case 2:Stop();goto re;case 3:Resume();goto re;case 6:FastForward();goto re;case 8:FastBack();goto re;case 4:StopStop();goto re;case 9:VolumePlus();goto re;case 10:VolumeReduce();goto re;case 5:Order--;PreSong();goto re;case 7:Order++;NextSong();goto re;case 12:ChooseSong();goto re;case 11:SelectCirculMode();goto re;case 13:mciSendString("close aa", NULL, 0, NULL);return;case 14:SaveExit();//getchar();}}else{goto epo;}};void NewOperation(){ee:int i=0;printf("请选择要进行的操作:");scanf("%d",&i);fflush(stdin);switch(i){case 1:FM_CheckFilePrint(0,Amount);begin = FM_Choose(Amount,begin);break;case 2:begin = FM_Path(begin);break;case 3:break;default:printf("输入有误\n");goto ee;}};void ShowNewList(){FM_List(begin,Amount);NewOrder=Amount+1;PlayOperation();}void ChooseSong(){int id = 0;printf("请输入歌曲号:");scanf("%d",&id);if(id<1||id>Amount){printf("选择歌曲不存在!\n");}else{char ch[200];mciSendString("close aa", NULL, 0, NULL);sprintf(ch,"open \"%s\" alias aa",info[id-1].add);mciSendString(ch,NULL,0,NULL);mciSendString("play aa repeat",NULL,0,NULL);}}。