🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.multimedia
Article #1160

Re: Playing and decoding MP3 files

#1160
From: Michael Crapo
Date: Fri, 17 Aug 2001 14:00
99 lines
3002 bytes
Don.

	You can build you own.  Look at http://www.id3.org/ to see the
standard for the ID3 Tag's version 1, 1.1 and 2

	Here is a example I found on how to read ID3tag1


Mike

// mp3mobile: read an ID3 tag
// altman@cryton.demon.co.uk
// Read an ID3 tag from a file into a songinfo struct: if there's no
ID3,
// make something up with the filename. The songinfo struct just has
// song, artist and year fields, along with other bits.
static int id3_read(char *tune,songinfo *s)
  {
  FILE *f; char buffer[256];

  /* Make pathname */
  sprintf(buffer,"%s%s",base_path,tune);

  /* Try to open the .mp3 */
  if ((f=fopen(buffer,"rb"))==NULL) return(1);

  /* Go to 128 bytes from the end */
  fseek(f,-128L,SEEK_END);

  /* Read the buffer */
  fread(buffer,1,128,f);
  fclose(f);

  /* Look for 'TAG' indicating ID3 tag */
  if (strncmp(buffer,"TAG",3)==0)
    {
    char *b=buffer+3,*c=b+29;

    /* Found tag, read out title & artist */
    while(c>b && *c==' ') c--;
    *++c=0;

    /* Save title */
    strcpy(s->song,b);

    b=buffer+33; c=b+29;
    while(c>b && *c==' ') c--;
    *++c=0;

    /* Save artist */
    strcpy(s->artist,b);

    /* Save year */
    if ((s->year=atoi(buffer+93))==0) s->year=9999;
    }
  else
    {
    char *b;

    /* Take first part of path as band, second as tune */
    strcpy(buffer,tune);

    /* Convert all _'s to spaces */
    b=buffer;
    while(*b) if (*b=='_') *b++=' '; else b++;

    if ((b=strchr(buffer,'/'))==NULL)
      {
      /* No path separator, just use filename as song */
      strcpy(s->song,buffer);
      s->artist[0]=0;
      }
    else
      {
      /* Separate them */
      *b++=0;
      strcpy(s->song,b);
      strcpy(s->artist,buffer);
      }
    }

  return(0);
  }



On Thu, 16 Aug 2001 12:08:39 -0700, "Don Wilcox" <dwilcox@dfsaz.com>
wrote:

>Hi.
>
>I am looking for a simple way to extract the MP3 header info from an MP3
>file. I can load and play the file using MediaPlayer, but it will not give
>me the additional info I need. Does anyone know where I can get a tool for
>this little feature?
>
>Don
>
>
Technical Details
Message-ID: <3b7d2335.3392528@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!193.174.75.178!news-fra1.dfn.de!news-lei1.dfn.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews
References: <3b7c1a74_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d0fc,c8f0438828f02836
X-Google-Attributes: gid10d0fc,public
X-Google-ArrivalTime: 2001-08-17 07:11:17 PST
From: mcrapo@tng-ida.com (Michael Crapo)
Newsgroups: borland.public.cppbuilder.multimedia
Subject: Re: Playing and decoding MP3 files
Date: Fri, 17 Aug 2001 14:00:38 GMT
Message-ID: <3b7d2335.3392528@newsgroups.borland.com>
References: <3b7c1a74_2@dnews>
X-Newsreader: Forte Free Agent 1.21/32.243
NNTP-Posting-Host: 207.170.242.1
X-Trace: dnews 998056930 207.170.242.1 (17 Aug 2001 07:02:10 -0700)
Lines: 100
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!193.174.75.178!news-fra1.dfn.de!news-lei1.dfn.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews