0
回答
mp3 id3v2 中图片数据的获取
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

FILE *fp;
 BYTE cID3V2_head[10];
 long ID3V2_len;
 BYTE cID3V2Fra_head[10];
 long lID3V2Fra_length;
 BYTE *cID3V2Fra;
 if ((fp=fopen("//My Documents//我的音乐//never say goodbye.mp3","rb"))==NULL)
 {
  MessageBox(NULL, _T("have no such file"), _T("notify"), MB_OK);
 }
 else
 {
  fread(cID3V2_head, 10, 1, fp);
  if ((cID3V2_head[0]=='I'||cID3V2_head[0]=='i')
   &&(cID3V2_head[1]=='D'||cID3V2_head[1]=='d')
   &&(cID3V2_head[2]=='3'))
  {
   ID3V2_len = (cID3V2_head[6]&0x7f)<<21
    | (cID3V2_head[7]&0x7f)<<14
    | (cID3V2_head[8]&0x7f)<<7
    | (cID3V2_head[9]&0x7f);
  }

  //get APIC
  while((ftell(fp)+10)<=ID3V2_len)
  {
   memset(cID3V2Fra_head, 0, 10);
   fread(cID3V2Fra_head, 10, 1, fp);

   lID3V2Fra_length = (long)(cID3V2Fra_head[4]*0x100000000
    + cID3V2Fra_head[5]*0x10000
    + cID3V2Fra_head[6]*0x100
    + cID3V2Fra_head[7]);

   if ((cID3V2Fra_head[0]=='A'||cID3V2Fra_head[0]=='a')
    &&(cID3V2Fra_head[1]=='P'||cID3V2Fra_head[1]=='p')
    &&(cID3V2Fra_head[2]=='I'||cID3V2Fra_head[2]=='i')
    &&(cID3V2Fra_head[3]=='C'||cID3V2Fra_head[3]=='c'))
   {

    //分配成功
    cID3V2Fra = (BYTE *)malloc(lID3V2Fra_length);
    if (cID3V2Fra!=NULL)
    {
     fread(cID3V2Fra, lID3V2Fra_length, 1, fp);
    }
    break;
   }
   else
   {
    fseek(fp, lID3V2Fra_length, SEEK_CUR);
   }
  }
 }
 fclose(fp);


原文链接:http://blog.csdn.net/favormm/article/details/4530912
<无标签>
举报
长平狐
发帖于5年前 0回/272阅
顶部