qfedu-c-level/lyric_analysis/srcs/main.c

31 lines
916 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "./includes/lrc.h"
#include "./includes/console.h"
#include "./includes/start_mplayer.h"
int main()
{
// 定义歌曲和歌词文件路径
const char *song_path = "../songs/简单爱.mp3";
const char *lrc_path = "../lrc/简单爱.lrc";
FILE *fp = open_lrc_file(lrc_path); // 打开歌词文件
if (NULL == fp)
{
printf("歌词打开失败\n");
perror("fopen");
return -1; // 打开歌词文件失败,退出程序
}
mplayer_play(song_path); // 启动mplayer播放器播放歌曲
long lrc_size = get_lrc_size(fp); // 获取并打印歌词文件大小
char *lrc_mem_data = (char *)malloc(lrc_size); // 为歌词数据分配内存
if (NULL == lrc_mem_data)
{
printf("歌词数据分配内存失败\n");
perror("malloc");
return -1; // 为歌词数据分配内存失败,退出程序
}
return 0;
}