#include<stdio.h>
#include<malloc.h>
#include<string.h>
#include<windows.h>
#include<stdlib.h>
#define SIZE 10000
#define LEN sizeof(LRC)
extern int x=20,y=6;
int count=0;
typedef struct lrc
{ int time;
char lyric[50];
struct lrc *next;
}LRC;
LRC lrchead[4];
char* Flrc(FILE *fp,char LrcBuf[])
{ int lrc_size;
lrc_size=fread(LrcBuf,1,10000,fp);
LrcBuf[lrc_size]='\0';
return LrcBuf;
}
void LrcHead(char *str)
{
int i=0,j=0;
char *p;
p=strstr(str,"[");
for(i=0;i<4;i++)
{ j=0;
p+=4;
while(*p!=']')
{
lrchead[i].lyric[j++]=*p++;
}
lrchead[i].lyric[j]='\0';
p=strstr(p,"[");
}
}
void Message_Song_Play( )
{
char *name[4]={"歌曲","歌手","专辑","制作"};
int i;
for(i=0;i<4;i++)
{
printf("%s\t\t%s\n",name[i],lrchead[i].lyric);
}
}
LRC * LrcRead(char *str)
{
int i=0;
int count;
char *p;
char *temp;
char lrc[50];
char *plrc;
LRC *pf,*pb;
LRC *head=NULL;
p=strstr(str,"[0");
while(*p != '\0')
{
if ( *p=='[' && *(p+1)=='0')
{
count=(*(p+2)-'0')*60+(*(p+4)-'0')*10+*(p+5)-'0';
p=p+10;
temp=p;
while(*temp=='[' && *(temp+1)=='0')
temp+=10;
plrc=lrc;
while(*temp!='\n')
{
*plrc++=*temp++;
}
*plrc='\0';
pb = (LRC*)malloc(LEN);
pb->time=count;
strcpy(pb->lyric,lrc);
//printf("%d %s\n",pb->time,pb->lyric);
if(i == 0)
{
head = pf = pb;
i++;
}
else
{
pf->next = pb;
pf=pb;
pb->next=NULL;
}
}
p++;
}
return head;
}
//获取当前光标位置,并存放到变量 x,y中
void whereXY(int *x,int *y)
{
HANDLE h1;
CONSOLE_SCREEN_BUFFER_INFO scrInfo;
h1=GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(h1,&scrInfo);
*x=scrInfo.dwCursorPosition.X;
*y=scrInfo.dwCursorPosition.Y;
}
//跳转到光标指定位置
void GoToXY(int x,int y)
{
HANDLE h1;
COORD pos;
pos.X=x;
pos.Y=y;
h1=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(h1,pos);
}
void FreeStruct(LRC *head)
{
LRC *p;
while(head != NULL)
{
p = head->next;
free(head);
head = p;
}
exit(0);
}
void SortLrc(LRC *head)
{
LRC *point1;
LRC *point2;
LRC *temp1;
LRC *temp2;
LRC st;
if(head==NULL)
{
printf("歌词信息为空!\n");
}
point1 = point2 = head;
while(point1 != NULL)
{
point2 = point1;
while(point2 != NULL)
{
if(point1->time > point2->time)
{
temp1 = point1->next;
temp2 = point2->next;
st = *point1;
*point1 = *point2;
*point2 = st;
point2->next = temp2;
point1->next = temp1;
}
point2 = point2->next;
}
point1 = point1->next;
}
}
void main( )
{
int i=1,j=0;
int second=0;
int minute=0;
int sum;
int count=0;
char LrcBuf[SIZE];
LRC *lrclist;
LRC *temp;
LRC *point;
LRC *head;
FILE *fp;
if ((fp = fopen("简单爱.lrc", "r")) == NULL) //判断student文件是否存在
{
printf ("Cans not open this file\n"); //建立不成功输出出错信息
exit(0);
}
Flrc(fp,LrcBuf);
LrcHead(LrcBuf);
Message_Song_Play( );
lrclist=LrcRead(LrcBuf);
SortLrc(lrclist);
ShellExecute( NULL, NULL, "TTPlayer.exe",".\\简单爱.mp3",NULL,1); //执行千千静听
temp=lrclist;
head=lrclist;
while(temp != NULL)
{
Sleep(1000);
if(second++==60)
{ minute++;
second=0;
}
sum=minute*60+second;
GoToXY(25, 5);
printf("%02d:%02d\n",minute,second);
if(temp->time==sum)
{
if(count<8)
{
GoToXY(x,y);
printf("\t\t%s\n",temp->lyric);
whereXY(&x,&y);
temp=temp->next;
count++;
}
else
{
system("cls");
Message_Song_Play( );
point=lrclist->next;
GoToXY(25, 5);
printf("%02d:%02d\n",minute,second);
GoToXY(20, 6);
for(j=0;j<8;j++)
{
GoToXY(x,6+j);
printf("\t\t%s\n",point->lyric);
whereXY(&x,&y);
point=point->next;
}
lrclist=lrclist->next;
temp=temp->next;
}
}
}
FreeStruct(head);
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
LRC.rar (16个子文件)
LRC
lrc.plg 721B
lrc.dsw 529B
lrc.c 4KB
lrc.dsp 3KB
lrc.ncb 33KB
Debug
lrc.ilk 203KB
lrc.pdb 489KB
vc60.idb 41KB
简单爱.mp3 5.17MB
lrc.pch 2.66MB
vc60.pdb 68KB
lrc.obj 20KB
lrc.exe 168KB
简单爱.lrc 1KB
简单爱.lrc 1KB
lrc.opt 48KB
共 16 条
- 1
资源评论
- xuanfeng0072012-10-31写的还行,有些特殊文本格式读不出来
- 沧兰2018-08-09有点问题啊
- 小猴爷2013-11-03还是可以的,不过看的有点乱!光标设置有点问题
- 南宫小菜菜2012-12-22看过了,挺好的。歌词是解析出来了,跟千千静听显示的有点出入。
dfxxm
- 粉丝: 0
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功