日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

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

發布時間:2025/3/20 c/c++ 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 项目: 用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();//加載周杰倫曲目圖像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); //循環播放音樂menu_zhou();settextcolor(RED);outtextxy(6,472,"正在播放: 愛的飛行日記");break;case 'b':mciSendString("open 1稻香.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);menu_zhou();settextcolor(RED);outtextxy(6,472,"正在播放: 稻香");break;case 'c':mciSendString("open 1七里香.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); menu_zhou();settextcolor(RED);outtextxy(6,472,"正在播放: 七里香");break;case 'd':mciSendString("open 1晴天.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);menu_zhou();settextcolor(RED);outtextxy(6,472,"正在播放: 晴天");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,450,"help:請輸入你想聽的歌曲所對應的字母"); } void linjunjie()//林俊杰歌曲 {char input;menu_linjunjie();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);menu_linjunjie();settextcolor(YELLOW);outtextxy(6,472,"正在播放: 被風吹過的夏天");break;case 'b':mciSendString("open 2心.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); menu_linjunjie();settextcolor(YELLOW);outtextxy(6,472,"正在播放: 心墻");break;case 'c':mciSendString("open 2她說.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);menu_linjunjie();settextcolor(YELLOW);outtextxy(6,472,"正在播放: 她說");break;case 'd':mciSendString("open 2愛笑的眼睛.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); menu_linjunjie();settextcolor(YELLOW);outtextxy(6,472,"正在播放: 愛笑的眼睛");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();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);menu_xusong();settextcolor(RED);outtextxy(6,472,"正在播放: 幻聽");break;case 'b':mciSendString("open 3素顏.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);menu_xusong();settextcolor(RED);outtextxy(6,472,"正在播放: 素顏");break;case 'c':mciSendString("open 3灰色頭像.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);menu_xusong();settextcolor(RED);outtextxy(6,472,"正在播放: 灰色頭像");break;case 'd':mciSendString("open 3玫瑰花的葬禮.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); menu_xusong();settextcolor(RED);outtextxy(6,472,"正在播放: 玫瑰花的葬禮");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();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); menu_qita();outtextxy(6,472,"正在播放: Love Story");break;case 'b':mciSendString("open 認真的老去.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);menu_qita();outtextxy(6,472,"正在播放: 認真的老去");break;case 'c':mciSendString("open 星.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); menu_qita();outtextxy(6,472,"正在播放: 夜空中最亮的星");break;case 'd':mciSendString("open 無名之輩.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); menu_qita();outtextxy(6,472,"正在播放: 無名之輩");break;case 'e':mciSendString("open 不知所措.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);menu_qita();outtextxy(6,472,"正在播放: 不知所措");break;case 'f':mciSendString("open 十年.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL);menu_qita();outtextxy(6,472,"正在播放: 十年");break;case 'g':mciSendString("open 勛章.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); menu_qita();outtextxy(6,472,"正在播放: 勛章");break;case 'h':mciSendString("open 夜航星.mp3 alias bkmusic", NULL, 0, NULL);mciSendString("play bkmusic repeat", NULL, 0, NULL); menu_qita();outtextxy(6,472,"正在播放: 夜航星");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; }

資源地址

鏈接:https://pan.baidu.com/s/1Zp1AtEclmHzwd6KWMZSY5Q 提取碼:1234

總結

以上是生活随笔為你收集整理的项目: 用C语言写一个图形化的音乐播放器 【C++ / C】的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。