把握命运,追逐梦想

对自己所做的事要有兴趣,同时还要能够坚持不懈

统计

留言簿(1)

阅读排行榜

评论排行榜

读取mp3文件的尾部信息

#include<string.h>
#include
<stdio.h>
struct Infomation
{
    
char tag[4];
    
char name[31];
    
char singer[31];
    
char aname[31];
    
char year[5];
    
char content[29];
    
char other[4];
}
;

int main()
{
    FILE 
*pFile;
    pFile 
= fopen("11.mp3","r+");

    
char strbuf[129];

    fseek(pFile,
-128,2);
    
    
int ret = 0;

    ret 
= fread(strbuf,128,1,pFile);

    Infomation a;
    memset(
&a,0,sizeof(Infomation));

    rewind(pFile);

    memcpy(
&a.tag,strbuf,3);
    memcpy(
&a.name,&strbuf[3],30);

    memcpy(
&a.singer,&strbuf[33],30);
    memcpy(
&a.aname,&strbuf[63],30);
    memcpy(
&a.year,&strbuf[93],4);
    memcpy(
&a.content,&strbuf[97],28);
    memcpy(
&a.other,&strbuf[125],3);

    printf(
"%s\n",a.tag);
    printf(
"%s\n",a.name);
    printf(
"%s\n",a.singer);
    printf(
"%s\n",a.aname);
    printf(
"%s\n",a.year);
    printf(
"%s\n",a.content);
    printf(
"%s\n",a.other);

    fclose(pFile);
    
return 0;

}

//
//MP3歌曲的基本信息存在了MP3文件的最后128个字节里,
//其结构是:
//1-3 TAG 
//4-33 歌曲名(Take Me To Your Heart )
//34-63 歌手名(Michael Learns to Rock)
//64-93 专辑名(Take Me to Your Heart)
//94-97 年(2004)
//98-125 备注 (http://www.uptu.com
//126 保留位,这时为0,则说明有音轨,下一位就是音轨
//127 保留位,为音轨(第几首歌)(OC)
//128 保留位 (风格)(66)
//请写出一个读取MP3歌曲信息的函数,将信息存放在结构成员变量中。

posted on 2009-07-29 15:20 把握命运 阅读(541) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理