600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 项目: 用C语言写一个精美图形化的音乐播放器【C++ / C】

项目: 用C语言写一个精美图形化的音乐播放器【C++ / C】

时间:2023-11-20 14:03:52

相关推荐

项目: 用C语言写一个精美图形化的音乐播放器【C++ / C】

目录

最终效果代码资源地址

最终效果

代码

/************1开头的是周杰伦的歌2开头的是林俊杰的歌3开头的是许嵩的歌*************/#include<stdio.h>#include<windows.h>#include<mmsystem.h>#pragma comment(lib,"Winmm.lib")#include<graphics.h>#include<stdlib.h>#include<conio.h>void zhoujielun();void menu_zhou();void linjunjie();void menu_linjunjie();void xusong();void menu_xusong();void qita();void menu_qita();void menu();#define width 400//窗口的大小#define height 500int i=0;void zhoujielun()//周杰伦歌曲{char input;menu_zhou();//加载周杰伦曲目图像IMAGE imga,imgb,imgc,imgd;loadimage(&imga,"1爱的飞行日记.png",145,42);loadimage(&imgb,"1稻香.png",145,42);loadimage(&imgc,"1七里香.png",145,42);loadimage(&imgd,"1晴天.png",145,42);while(1){if(kbhit())//判断是否有输入{mciSendString("close bkmusic", NULL, 0, NULL);//关闭歌曲input=getch();if(input=='e')break;switch(input){case 'a':mciSendString("open 1爱的飞行日记.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); //循环播放音乐putimage(6,465,&imga);break;case 'b':mciSendString("open 1稻香.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);putimage(6,465,&imgb);break;case 'c':mciSendString("open 1七里香.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); putimage(6,465,&imgc);break;case 'd':mciSendString("open 1晴天.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);putimage(6,465,&imgd);break;}}}}void menu_zhou(){char input;IMAGE mg;cleardevice();loadimage(&mg,"周杰伦.png",400,500);putimage(0,0,&mg);settextcolor(CYAN);settextstyle(28,0,"宋体");outtextxy(130,20,"周杰伦曲目");settextstyle(24,0,"宋体");outtextxy(122,90,"a. 爱的飞行日记");outtextxy(124,170,"b. 稻香");outtextxy(124,240,"c. 七里香");outtextxy(124,310,"d. 晴天");outtextxy(124,380,"e. 返回主菜单");settextstyle(18,0,"宋体");outtextxy(6,440,"help:请输入你想听的歌曲所对应的字母");}void linjunjie()//林俊杰歌曲{char input;IMAGE imga,imgb,imgc,imgd;menu_linjunjie();loadimage(&imga,"2被风吹过的夏天.png",145,42);loadimage(&imgb,"2心墙.png",145,42);loadimage(&imgc,"2她说.png",145,42);loadimage(&imgd,"2爱笑的眼睛.png",145,42);while(1){if(kbhit())//判断是否有输入{mciSendString("close bkmusic", NULL, 0, NULL);//关闭歌曲input=getch();if(input=='e')break;switch(input){case 'a':mciSendString("open 2被风吹过的夏天.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);putimage(6,465,&imga);break;case 'b':mciSendString("open 2心.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); putimage(6,465,&imgb);break;case 'c':mciSendString("open 2她说.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);putimage(6,465,&imgc);break;case 'd':mciSendString("open 2爱笑的眼睛.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); putimage(6,465,&imgd);break;}}}}void menu_linjunjie(){char input;IMAGE mg;cleardevice();loadimage(&mg,"林俊杰.png",400,500);putimage(0,0,&mg);settextcolor(GREEN);settextstyle(28,0,"宋体");outtextxy(135,20,"林俊杰曲目");settextstyle(24,0,"宋体");outtextxy(122,90,"a. 被风吹过的夏天 ");outtextxy(124,160,"b. 心墙");outtextxy(124,230,"c. 她说");outtextxy(124,300,"d. 爱笑的眼睛");outtextxy(124,370,"e. 返回主菜单");settextstyle(18,0,"宋体");outtextxy(6,440,"help:请输入你想听的歌曲所对应的字母");}void xusong()//许嵩歌曲{char input;menu_xusong();IMAGE imga,imgb,imgc,imgd;loadimage(&imga,"3幻听.png",145,42);loadimage(&imgb,"3素颜.png",145,42);loadimage(&imgc,"3灰色头像.png",145,42);loadimage(&imgd,"3玫瑰花的葬礼.png",145,42);while(1){if(kbhit())//判断是否有输入{mciSendString("close bkmusic", NULL, 0, NULL);input=getch();if(input=='e')break;switch(input){case 'a':mciSendString("open 3幻听.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);putimage(6,465,&imga);break;case 'b':mciSendString("open 3素颜.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);putimage(6,465,&imgb);break;case 'c':mciSendString("open 3灰色头像.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);putimage(6,465,&imgc);break;case 'd':mciSendString("open 3玫瑰花的葬礼.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); putimage(6,465,&imgd);break;}}}}void menu_xusong(){char input;IMAGE mg;cleardevice();loadimage(&mg,"许嵩.png",400,500);putimage(0,0,&mg);settextcolor(GREEN);settextstyle(28,0,"宋体");outtextxy(135,20,"许嵩曲目");settextstyle(24,0,"宋体");outtextxy(122,90,"a. 幻听 ");outtextxy(124,160,"b. 素颜");outtextxy(124,230,"c. 灰色头像");outtextxy(124,300,"d. 玫瑰花的葬礼");outtextxy(124,370,"e. 返回主菜单");settextstyle(18,0,"宋体");outtextxy(6,440,"help:请输入你想听的歌曲所对应的字母");}void qita()//混杂曲库{char input;menu_qita();IMAGE imga,imgb,imgc,imgd,imge,imgf,imgg,imgh;loadimage(&imga,"Love.png",145,42);loadimage(&imgb,"认真的老去.png",145,42);loadimage(&imgc,"星.png",145,42);loadimage(&imgd,"无名之辈.png",145,42);loadimage(&imge,"不知所措.png",145,42);loadimage(&imgf,"十年.png",145,42);loadimage(&imgg,"勋章.png",145,42);loadimage(&imgh,"夜航星.png",145,42);while(1){if(kbhit())//判断是否有输入{mciSendString("close bkmusic", NULL, 0, NULL);input=getch();if(input=='i')break;switch(input){case 'a':mciSendString("open Love.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); putimage(6,465,&imga);break;case 'b':mciSendString("open 认真的老去.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);putimage(6,465,&imgb);break;case 'c':mciSendString("open 星.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); putimage(6,465,&imgc);break;case 'd':mciSendString("open 无名之辈.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); putimage(6,465,&imgd);break;case 'e':mciSendString("open 不知所措.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);putimage(6,465,&imge);break;case 'f':mciSendString("open 十年.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);putimage(6,465,&imgf);break;case 'g':mciSendString("open 勋章.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); putimage(6,465,&imgg);break;case 'h':mciSendString("open 夜航星.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); putimage(6,465,&imgh);break;}}}}void menu_qita(){char input;IMAGE mg;cleardevice();loadimage(&mg,"其他.png",400,500);putimage(0,0,&mg);settextcolor(RED);settextstyle(28,0,"宋体");outtextxy(135,20,"混杂曲库");settextstyle(24,0,"宋体");outtextxy(20,90,"a.Love Story");outtextxy(220,90,"b.认真的老去 ");outtextxy(20,160,"c.夜空中最亮的星");outtextxy(220,160,"d.无名之辈");outtextxy(20,230,"e.不知所措");outtextxy(220,230,"f.十年");outtextxy(20,300,"g.勋章");outtextxy(220,300,"h.夜航星");outtextxy(100,370,"i.返回主菜单");settextstyle(18,0,"宋体");settextcolor(YELLOW);outtextxy(6,440,"help:请输入你想听的歌曲所对应的字母");}void mi(){char input;IMAGE mg;cleardevice();loadimage(&mg,"作者.png",400,500);putimage(0,0,&mg);settextcolor(RED);settextstyle(28,0,"宋体");outtextxy(135,20,"作者简介");settextstyle(16,0,"宋体");outtextxy(10,60,"作者辉小歌,");outtextxy(10,100,"是一个正在努力学习的菜鸟");outtextxy(10,140,"作者在这里谢谢大家的使用!");outtextxy(100,370,"a.返回主菜单");while(1){input=getch();if(input=='a')break;}}void menu(){char input;IMAGE mg;loadimage(&mg,"1.png",400,500);//加载图片putimage(0,0,&mg);//从起点绘制图片settextcolor(YELLOW);//设置字体颜色settextstyle(28,0,"consolas");//设置字体大小和格式setbkmode(TRANSPARENT);//去掉字体输出的黑色背景outtextxy(114,15,"炫歌电台为你服务");settextstyle(24,0,"宋体");outtextxy(124,90,"a. 周杰伦");outtextxy(124,150,"b. 林俊杰");outtextxy(124,210,"c. 许嵩");outtextxy(126,270,"d. 混杂曲库");outtextxy(128,330,"e. 关于作者");outtextxy(130,390,"f. 退出");settextstyle(16,0,"consolas");outtextxy(10,440,"请输入你想听的歌手所对应的字母");outtextxy(10,460,"例: 听周杰伦 请按 a(小写)");input=_getch();switch(input){case 'a':zhoujielun();break;case 'b':linjunjie();break;case 'c':xusong();break;case 'd':qita();break;case 'e':mi();break;case 'f':i++;closegraph();break;}}int main(void){initgraph(width,height);while(1){menu();if(i==1){return 0;break;}}return 0;}

资源地址

链接:/s/1-T8SoWwpC5iX7xEte1dSkQ 提取码:1234

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。