⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mp4.cpp

📁 MP4源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			case 9:
				if(rgtSowMsg==1)
				{	
					rgtSowMsg=2;
					btnFilMsg.SetDefText("歌曲列表");
					btnFilMsg.SetText("歌曲列表",	btnFilMsg.imgSkim,	0xca7788,WHITE);
				}
				else if(rgtSowMsg==2)
				{
					rgtSowMsg=1;
					btnFilMsg.SetDefText("歌曲信息");
					btnFilMsg.SetText("歌曲信息",	btnFilMsg.imgSkim,	0xca7788,WHITE);
				}
				break;
			}

			if(rgtSowMsg==1)
			{
				SowAllFil(imgBg3);
				if(state==1&&haveLrc==1)ShowLrc(imgBg3);//显示歌词
			}
			else if(rgtSowMsg==2)SowCocFil(imgBg3);

			btnPlyCtl.Render	(imgBg3,1);
			btnNxtMus.Render	(imgBg3,1);
			btnLstMus.Render	(imgBg3,1);
			btnVocUpr.Render	(imgBg3,1);
			btnVocDnr.Render	(imgBg3,1);
			btnFilAdd.Render	(imgBg3,1);
			btnHlp.Render		(imgBg3,1);
			btnExt.Render		(imgBg3,1);
			btnSet.Render		(imgBg3,1);
			btnFilMsg.Render	(imgBg3,1);

			//更新屏幕图像
			putimage(0,0,imgBg3);
			delay_jfps(300);
		}
	}
	EndBatchDraw();
	//似乎没必要释放//btnPlyCtl.~GBUTTON();btnNxtMus.~GBUTTON();btnLstMus.~GBUTTON();btnVocUpr.~GBUTTON();btnVocDnr.~GBUTTON();btnFilAdd.~GBUTTON();btnHlp.~GBUTTON();btnExt.~GBUTTON();btnSet.~GBUTTON();btnFilMsg.~GBUTTON();
}

void ShowWcm()
{
	putimage(0,0,imgBg1);
	for(int y=0;y>-350;y-=picMovSpd)
	{
		putimage(imgBg3,0,0,imgBg2);
		putimage(imgBg3,0,y,imgBg1);
		putimage(0,0,imgBg3);
		delay(5);
	}
}
void ShowLrc(PIMAGE dest)
{
	int id;
	
	setcolor(YELLOW,dest);
	outtextxy(50,160,aLrc.LrcTimeReturnString().c_str(),dest);
	
	id=aLrc.GetNowLrcId();//此id为下一条
	setcolor(LIGHTGREEN,dest);

	if(id>2)outtextxy(50,120,aLrc.GetString(id-3).c_str(),dest);
	if(id>1)outtextxy(50,140,aLrc.GetString(id-2).c_str(),dest);
	if(id<=aLrc.GetLrcSum())outtextxy(50,180,aLrc.GetString(id).c_str(),dest);
	if(id+1<=aLrc.GetLrcSum())outtextxy(50,200,aLrc.GetString(id+1).c_str(),dest);
}
void SowAllFil(PIMAGE dest)
{
	if(filMaxId>=0)
	{
		if(state==1)
			setcolor(LIGHTGREEN,dest);
		else
			setcolor(YELLOW,dest);
		string str;
		str=music[filCocId].GetFileName();
		GetMidPos(600,textwidth(str.c_str()));
		outtextxy(320,160,str.c_str(),dest);
		setcolor(BLUE,dest);
		for(int i=0;i<=filMaxId;++i)
		{
			if(i!=filCocId)
			{
				str=music[i].GetFileName(2);
				outtextxy(350,160-filCocId*16+i*16,str.c_str(),dest);
			}
		}
		str.~string();
	}
}

void GetAFile()
{
	if (GetOpenFileName(&ofn))
	{
		++filMaxId;
		music[filMaxId].Init(szFile);
	}
	//ofn.~OPENFILENAME();
}

void SowSysMsg()
{
	for(int x=0;x>-600;x-=picMovSpd)
	{
		putimage(x,0,imgBg2);
		putimage(x+600,0,imgBg1);
		delay(5);
	}
	putimage(0,0,imgBg1);
	setcolor(LIGHTRED);
	outtextxy(200,25,"HELLO!欢迎使用追风逐月MP3 5.0");
	outtextxy(0,50,"功能有:");
	outtextxy(0,75,"1.更新:普通模式CPU功耗降低%60,最小化进入休眠模式,功耗降低%90");
	outtextxy(0,100,"2.全新界面,绚丽动态效果");
	outtextxy(0,125,"3.自动加载演唱者图片,请将 歌手名.jpg 图像放入程序所在的MP4\\Artist\\文件夹中");
	outtextxy(0,150,"4.加入自动歌词显示");
	outtextxy(0,175,"5.多种其他功能敬请挖掘!");
	outtextxy(350,200,"作者:王瀚兴 QQ:997205816");
	outtextxy(300,225,"本稿输入时间:2012年7月4日3:39:21");
	int btnId=-1;
	GBUTTON btnRtn1("返回",1,190,300,100,40);
	GBUTTON btnRtn2("帮助",2,290,300,100,40);
	while(btnId)
	{
		btnId=-1;
		btnRtn1.Update(&mouse,&btnId);
		btnRtn2.Update(&mouse,&btnId);
		btnRtn1.Render();
		btnRtn2.Render();
		switch(btnId)
		{
		case 1:
			btnId=0;//退出
			break;
		case 2:
			putimage(0,0,imgBg1);
			outtextxy(0,25,"1 界面图像消失:检查程序名,必须是MP4.exe,严格要求大小写正确");
			outtextxy(0,50,"                检查程序所在文件夹是否存在名为MP4的文件夹以及图片存在");
			outtextxy(0,75,"2.不能显示演唱者:按1步检查,再看MP4文件夹下是否有Artist文件夹");
			outtextxy(0,100,"               检查.mp3歌曲的ID3信息,修改mp3的参与创作的艺术家为演唱者名字");
			outtextxy(0,125,"               检查 \\MP4\\Artist\\演唱者姓名.jpg 是否存在,注意.jpg小写");
			outtextxy(0,150,"3.各文件名,文件夹名大小写均不可错误。");
			outtextxy(0,175,"bg.jpg/bgdef.jpg背景图可随意替换,不限大小。");
			outtextxy(0,200,"Mp3Changer.exe为Mp3修改器,修改Mp3TagBuffer.txt文件内路径歌曲");
			outtextxy(0,225,"SongList.txt是保存的历史歌曲列表");
			outtextxy(0,250,"Artist文件夹内为歌手图像,名字严格为 歌手名.jpg(小写)");
			break;
		}
		delay_jfps(300);
	}
	for(x=0;x<600;x+=picMovSpd)
	{
		putimage(x,0,imgBg1);
		putimage(x-600,0,imgBg2);
		delay(5);
	}
	setcolor(LIGHTBLUE);
//	btnRtn1.~GBUTTON();btnRtn2.~GBUTTON();
}


void Settings()
{
	int i;
	delete &i;

	string strbuf;
	fstream f1;
	sprintf(ArtistPath,"%sMP4\\SongList.txt",nowPath);
	for(int x=0;x<600;x+=picMovSpd)
	{
		putimage(x,0,imgBg3);
		putimage(x-600,0,imgBg2);
		delay(5);
	}
	putimage(0,0,imgBg2);
	outtextxy(0,50,"    (*^__^*) 嘻嘻……我正在想怎么添加些按钮呢...");
	int btnId=-1;
	GBUTTON btnLine("循环播放",0,140,300,100,50);
	GBUTTON btnRond("单曲重复",1,240,300,100,50);
	GBUTTON btnRndm("随机播放",2,340,300,100,50);	if(filMaxId<1)btnRndm.SetText("歌曲<2首禁用",btnRndm.imgSkim,YELLOW,LIGHTMAGENTA);
	GBUTTON btnSetMusArt("修改MP3",3,140,250,100,50);btnSetMusArt.SetText("!修改MP3",btnSetMusArt.imgSkim,YELLOW,LIGHTMAGENTA);
	GBUTTON btnMusLstSav("保存当前列表",4,240,250,100,50);
	GBUTTON btnMusLstLod("加载上次列表",5,340,250,100,50);
	GBUTTON btnRtrn("返回主界面",6,500,10,100,40);
	while(btnId==-1)
	{
		btnRond.Update(&mouse,&btnId);
		btnLine.Update(&mouse,&btnId);
		btnRndm.Update(&mouse,&btnId);
		btnSetMusArt.Update	(&mouse,&btnId);
		btnMusLstSav.Update (&mouse,&btnId);
		btnMusLstLod.Update (&mouse,&btnId);
		btnRtrn.Update(&mouse,&btnId);
		
		btnRond.Render();
		btnLine.Render();
		btnRndm.Render();
		btnSetMusArt.Render();
		btnMusLstSav.Render();
		btnMusLstLod.Render();
		btnRtrn.Render();

		switch(btnId)
		{
		case 0:
			plyMod=1;
			break;
		case 1:
			plyMod=2;
			break;
		case 2:
			if(filMaxId>0)plyMod=3;
			break;
		case 3:
			if(filMaxId<0)
			{
				MessageBox(myHwnd,"未选择任何歌曲,禁止使用!","警告!",MB_OK);
				break;
			}
			if(state==1)state=0;
			sprintf(ArtistPath,"%sMP4\\Mp3TagBuffer.txt",nowPath);
			f1.open(ArtistPath,ios::out);
			if(!f1.fail())
			{
				f1<<music[filCocId].GetFileName(1)<<endl;
				f1.close();
				delay(1000);
				sprintf(ArtistPath,"start %sMP4\\Mp3Changer.exe",nowPath);
				system(ArtistPath);
			}
			f1.close();
			break;
		case 4://保存当前列表
			f1.open(ArtistPath,ios::out);
			for(i=0;i<=filMaxId;++i)
			{
				f1<<music[i].GetFileName(1)<<endl;
			}
			f1.close();
			break;
		case 5://加载上次列表
			if(state==1)state=0;
			delay(1000);
			f1.open(ArtistPath,ios::in);
			if(f1.fail())
			{
				f1.close();
				MessageBox(myHwnd,"请确认列表和列表内文件路径正确!","加载列表失败!",MB_OK);
				break;
			}
			filMaxId=-1;
			filCocId=0;
			plyMod=1;//1循环播放 2单曲重复 3随机重复
			fisTim=1;
			haveArtistJpg=false;
			haveLrc=false;
			paused=false;

			for(;getline(f1,strbuf);)
			{
				++filMaxId;
				sprintf(szFile,"%s",strbuf.c_str());
				music[filMaxId].Init(szFile);
			}
			f1.close();
			break;
		case 6:
			break;
		}
		delay_jfps(300);
	}
	IMAGE imgBuf2;
	getimage(&imgBuf2,0,0,600,350);
	for(x=0;x>-600;x-=picMovSpd)
	{
		putimage(x,0,&imgBuf2);
		putimage(x+600,0,imgBg3);
		delay(5);
	}
	imgBuf2.~IMAGE();
	strbuf.~string();
//	f1.~fstream();//测试不会崩溃 但是放到别的文件夹就崩溃,不知何故
//	btnLine.~GBUTTON();btnRond.~GBUTTON();btnRndm.~GBUTTON();btnSetMusArt.~GBUTTON();btnMusLstSav.~GBUTTON();btnMusLstLod.~GBUTTON(); btnRtrn.~GBUTTON();
}

void SowCocFil(PIMAGE dest)
{
	setcolor(LIGHTCYAN,dest);
	outtextxy(100,80," 歌曲名: ",dest);
	outtextxy(100,100," 演唱者: ",dest);
	outtextxy(100,120,"所属专辑:",dest);
	outtextxy(100,140," 时间:  ",dest);
	outtextxy(100,160," 备注:  ",dest);

	if(filMaxId>=0&&state!=0)
	{
		setcolor(YELLOW,dest);
		outtextxy(200,80,aMp3.GetTitle(),dest);
		outtextxy(200,100,aMp3.GetArtist(),dest);
		outtextxy(200,120,aMp3.GetAlbum(),dest);
		outtextxy(200,140,aMp3.GetYear(),dest);
		outtextxy(200,160,aMp3.GetComment(),dest);
	}
}
void SetMyWindowTitle(string fis,string las)
{
	fis=fis+las;
	SetWindowText(myHwnd,fis.c_str());
}
void ArtistPicInit()//return path
{
	PIMAGE imgbuf;
	imgbuf=new IMAGE;
	sprintf(ArtistPath,"%sMP4\\Artist\\%s.jpg",nowPath,aMp3.GetArtist());
	if(!access(ArtistPath,0))//文件存在
	{	
		getimage(imgbuf,ArtistPath);
		float w=imgbuf->getwidth();
		float h=imgbuf->getheight();
		float mul;//放大倍数
		if(w>h)	mul=450/w;
		else	mul=300/h;
		imgArtist->getimage(0,0,w*mul,h*mul);
		putimage(imgArtist,0,0,w*mul,h*mul,imgbuf,0,0,w,h);
		haveArtistJpg=true;
	}
	else
	{haveArtistJpg=false;}
	delete imgbuf;
}

void Ext()
{
	KillTimer(myHwnd,1);
	KillTimer(myHwnd,2);
	for(int y=-350;y<0;y+=picMovSpd)
	{
		putimage(0,y,imgBg1);
		delay(5);
	}
	EndBatchDraw();
	delay(200);
	
	if(filMaxId>=0&&state!=0)music[filCocId].Stop();
	
	aMp3.~MP3INFO();
	aLrc.~LRCPLAYER();
	delete imgBg1,imgBg2,imgBg3,imgArtist;
	exit(0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -