主界面
代码
文件结构
face.h
#include<stdio.h>
int face_user();
int face_play();
int face_play2();
void face_fileFailure();
void face_userNotFound();
void face_passwordWrong();
void face_welcome(struct user* p);
char* input_AC();
char* input_re_AC();
char* input_PW();
void face_newACsuc();
void listMedia(struct media* head);
void listSongList(struct list* head);
list.h
#include<stdio.h>
#include<stdlib.h>
#include <Windows.h>
#include <mmsystem.h>
#include <io.h>
struct list {
int num;
char name[100];//歌单名称
struct list* next;
};
struct list* pre_list();
struct list* getChoice_list(struct list* head);
struct media* loadMedia(struct list* p);
play.h
#include <stdio.h>
#include <io.h>
struct media {
int num; // 编号
char name[100]; //歌曲名称
struct media* next; // 存储下一曲的地址
};
struct media* pre_media();
struct media* getChoice_media(struct media* head);
void play(struct media* p0);//播放
void pause(struct media* p0);//暂停播放
void continue_play(struct media* p0);//继续播放
void stop(struct media* p0);//停止播放
void volumeDown(struct media* p0);//音量减小
void volumeUp(struct media* p0);//音量增大
struct media* getNext(struct media* p0, struct media* head);
struct media* getLast(struct media* p0, struct media* head);
void volumeDown(struct media* p0);
void volumeUp(struct media* p0);
void switchPlay(struct media* p0);
char* getState(struct media* p0);
void goAhead15(struct media* p0);
void drawBack15(struct media* p0);
face.c
list.c
main.c
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include "mmsystem.h"
#include<string.h>
#include"face.h"
#include"play.h"
#include"list.h"
#define random(x) rand()%(x)
#pragma comment(lib,"winmm.lib")
int main() {
struct media* HEAD_MEDIA = NULL; //歌曲信息以链表形式存储,HEAD_MEDIA为链表头
struct list* HEAD_LIST = pre_list();//歌单信息以链表形式存储,HEAD_LIST为链表头
struct media* p_media = NULL;//指针,指向当前播放的歌曲的节点
struct list* p_list = NULL;
int choice;//储存选择的登录、注册或退出的选项
int choice_play = 0;//储存选择的播放功能的选项
int choice_song = 0;//储存选择的播放曲目的序号
int flag_play = 1;//记录播放状态,0表示退出播放
int choose;
BOOLEAN flag = 1;
char szTimeBuffer[1024];//当前播放音乐的位置
char szModeBuffer[1024];//当前播放音乐的状态
char szCommandBuffer[1024];
/*MymciSendString("open 03.mp3 alias BackMusic", NULL);
MymciSendString("play BackMusic", NULL);*/
HEAD_MEDIA = pre_media();
int loop = 0;
int randomPlay = 0;
listMedia(HEAD_MEDIA);//显示歌曲列表
p_media = getChoice_media(HEAD_MEDIA);//输入歌曲编号,返回指向对应歌曲信息的指针
play(p_media);
while (flag) {
choice = face_user();
switch (choice) {
case 1:
//MymciSendString("stop BackMusic", NULL);
//MymciSendString("open 03.mp3 alias BackMusic", NULL);
switchPlay(p_media);
break;
case 2:
switchPlay(p_media);
break;
case 3://单曲循环
loop = 1;
randomPlay = 0;
break;
case 4://列表循环
loop = 0;
randomPlay = 0;
break;
case 5://随机播放
randomPlay = 1;
loop = 0;
break;
case 6:
//上一首
if (loop == 1) {
loopPlay(p_media);
break;
}
if (randomPlay == 1) {
int song = random(5);
stop(p_media);
while (song--) {
p_media = getLast(p_media, HEAD_MEDIA);
}
play(p_media);
break;
}
stop(p_media);
p_media = getLast(p_media, HEAD_MEDIA);
play(p_media);
break;
case 7:
//下一首
if (loop == 1) {
loopPlay(p_media);
break;
}
if (randomPlay == 1) {
int song = random(5);
stop(p_media);
while (song--) {
p_media = getNext(p_media, HEAD_MEDIA);
}
play(p_media);
break;
}
stop(p_media);
p_media = getNext(p_media, HEAD_MEDIA);
play(p_media);
break;
case 8://查找音乐
HEAD_MEDIA = pre_media();
listMedia(HEAD_MEDIA);//显示歌曲列表
break;
case 9: //选曲播放
stop(p_media);
listMedia(HEAD_MEDIA);
p_media = getChoice_media(HEAD_MEDIA);
play(p_media);
break;
case 0:
flag = 0;
break;
default:
printf("输入错误,请重新输入...\n");
break;
}
printf("\n");
system("pause");
}
}
play.c
篇幅有限。想要完整代码,发我主页邮箱