Reading MP3 tags

Richard Gaskin ambassador at fourthworld.com
Sun Aug 3 18:35:01 EDT 2003


tkuypers at pandora.be wrote:

> Is there anyone who done something to read MP3 tags in RR?
> I want to create a little application to keep track of my music CD¹s and MP3
> files, but (lazy as I am) I don¹t want to enter all info of these files &
> CD¹s.
> The MP3 specs seem very straight-foreward, though to much to ³just do it², so
> if anyone wants me to give a quick look and receive oooohhhh and aaahhhhhh on
> the application he/she created... ;-)

Fortunately the spec makes it pretty easy.  I got annoyed with iTunes once
too many times the other day so I wrote a replacement for it in a few hours
that does just what I need.

To build the Library listing I walk through a list of folders and get the
size and file names from "the detailed files" -- I pass both to this
function to get the MP3 TAG info, which is stored in the last 128 bytes of
the file:

function MP3Info pFile, pSize
  open file pFile for read
  Err the result
  read from file pFile at (pSize - 127) for 128
  put it into tInfo
  close file pFile
  if char 1 to 3 of tInfo = "TAG" then
    put char 4 to 33 of tInfo into tTitle
    put char 34 to 63 of tInfo into tArtist
    put char 64 to 93 of tInfo into tAlbum
    put tTitle &tab& tArtist &tab& tAlbum into tInfo
    return tInfo
  else return tab&tab
end MP3Info

Note that my function only returns the track title, artist, and album --
there's more info as defined at <http://www.dv.co.yu/mpgscript/mpeghdr.htm>,
so you could make it more complete as you need.

If you find a way to get the playing duration I would be very grateful.

-- 
 Richard Gaskin 
 Fourth World Media Corporation
 Developer of WebMerge: Publish any database on any Web site
 ___________________________________________________________
 Ambassador at FourthWorld.com       http://www.FourthWorld.com
 Tel: 323-225-3717                       AIM: FourthWorldInc




More information about the use-livecode mailing list