Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Toggle Button Text
AutoSave
Change the LineSize of a Shape Sprite
zScript
Diffusion Effect - Imaging Lingo
Light Up
keyboard input control
Stop all the sounds
FilmLoop Controller
xMedia
MediaMacros Xtras Mall
 

 

 

Behavior get and set a mp3's ID3tag I !

Added on 8/26/2002

 

Compatibilities:
D8_5

This item has not yet been rated

Author: sbljx (website)

For Director only supports ID3Tag II, I have made tow functions based on fileIO xtra functions which can get and set ID3tag I of a mp3 file.cause I am lazy and have little time , I didn't make it a perfect completed one. you can make a further develop to fit your projects.welcome to www.aougu.com for mating. important: To run the funtions properly,you have to add the function copystr() which has been give below.

--put AGGetID3tags(the moviepath&"music.mp3")
-- [#track: 1, #title: "情深深雨濛濛", #artist: "赵薇", #album: "情深深雨濛濛", #year: "2001", #genre: 34, #comment: "情深深雨濛濛", #mpeginfo: [#size: 4568293, #length: 286171, #layer: 3]]

on AGGetID3tags ffilename
  tlist=[#Track: 0, #Title:"",#Artist:"",#Album:"",#Year:"",#Genre: 0, #Comment:"", #MpegInfo:[#Size: 0,#Length: 0,#Layer: 0]]
  tfileio=new(xtra"fileio")
  openfile(tfileio,ffilename,1)
  tlength= getLength(tfileio)
  ----------------
  tpos=tlength-128
  setPosition(tfileio,tpos)
  tstr=""
  repeat with i=tpos to tpos+2
    tchar= readchar(tfileio)
    if tchar="" then exit repeat
    put tchar after tstr
  end repeat
  if tstr<>"TAG" then return tlist
  ---------------
  tpos=tpos+3
  setPosition(tfileio,tpos)
  tstr=""
  repeat with i=tpos to tpos+29
    tchar= readchar(tfileio)
    if tchar="" then exit repeat
    put tchar after tstr
  end repeat
  tlist.Title=copystr(tstr,1,30)
  ---------------
  tpos=tpos+30
  setPosition(tfileio,tpos)
  tstr=""
  repeat with i=tpos to tpos+29
    tchar= readchar(tfileio)
    if tchar="" then exit repeat
    put tchar after tstr
  end repeat
  tlist.Artist=copystr(tstr,1,30)
  ---------------
  tpos=tpos+30
  setPosition(tfileio,tpos)
  tstr=""
  repeat with i=tpos to tpos+29
    tchar= readchar(tfileio)
    if tchar="" then exit repeat
    put tchar after tstr
  end repeat
  tlist.Album=copystr(tstr,1,30)
  ---------------
  tpos=tpos+30
  setPosition(tfileio,tpos)
  tstr=""
  repeat with i=tpos to tpos+3
    tchar= readchar(tfileio)
    if tchar="" then exit repeat
    put tchar after tstr
  end repeat
  tlist.Year=copystr(tstr,1,4)
  ---------------
  tpos=tpos+4
  setPosition(tfileio,tpos)
  tstr=""
  repeat with i=tpos to tpos+27
    tchar= readchar(tfileio)
    if tchar="" then exit repeat
    put tchar after tstr
  end repeat  
  tlist.Comment=copystr(tstr,1,28)
  ---------------
  tpos=tpos+29
  setPosition(tfileio,tpos)
  tchar= readchar(tfileio)
  tlist.Track=chartonum(tchar)
  ---------------
  tpos=tpos+1
  setPosition(tfileio,tpos)
  tchar= readchar(tfileio)
  tlist.Genre=chartonum(tchar)
  ---------------
  --mpeginfo
  tmember=new(#sound)
  tmember.filename=ffilename
  tlist.MpegInfo.Size=tlength
  tlist.MpegInfo.Length=tmember.duration
  tlist.MpegInfo.Layer=3
  tmember.erase()
  
  closefile(tfileio)
  tfileio=0
  return tlist
end
--taginfo=[#track: 1, #title: "情深深雨濛濛", #artist: "赵薇", #album: "情深深雨濛濛", #year: "2001", #genre: 34, #comment: "情深深雨濛濛"]
--AGWriteID3tags(the moviepath&"music.mp3",taginfo)
--put AGGetID3tags(the moviepath&"music.mp3")
-- [#track: 1, #title: "情深深雨濛濛", #artist: "赵薇", #album: "情深深雨濛濛", #year: "2001", #genre: 34, #comment: "情深深雨濛濛", #mpeginfo: [#size: 4568293, #length: 286171, #layer: 3]]

on AGWriteID3tags ffilename,flist
  tfileio=new(xtra"fileio")
  openfile(tfileio,ffilename,0)
  tlength= getLength(tfileio)
  ----------------
  tpos=tlength-128
  setPosition(tfileio,tpos)
  tstr=""
  repeat with i=tpos to tpos+2
    tchar= readchar(tfileio)
    if tchar="" then exit repeat
    put tchar after tstr
  end repeat
  if tstr<>"TAG" then
    tpos=tlength
    setPosition(tfileio,tpos)
    writeString(tfileio,"TAG")
  end if
  
  ---------------
  tpos=tpos+3
  ttpos=tpos
  repeat with i=1 to 30
    writeChar(tfileio,"")
    ttpos=ttpos+1
    setPosition(tfileio,ttpos)
  end repeat
  setPosition(tfileio,tpos)
  writeString(tfileio,copystr(flist.Title,1,30))
  ---------------
  tpos=tpos+30
  ttpos=tpos
  repeat with i=1 to 30
    writeChar(tfileio,"")
    ttpos=ttpos+1
    setPosition(tfileio,ttpos)
  end repeat
  setPosition(tfileio,tpos)
  writeString(tfileio,copystr(flist.artist,1,30))
  ---------------
  tpos=tpos+30
  ttpos=tpos
  repeat with i=1 to 30
    writeChar(tfileio,"")
    ttpos=ttpos+1
    setPosition(tfileio,ttpos)
  end repeat
  setPosition(tfileio,tpos)
  writeString(tfileio,copystr(flist.album,1,30))
  ---------------
  tpos=tpos+30
  ttpos=tpos
  repeat with i=1 to 4
    writeChar(tfileio,"")
    ttpos=ttpos+1
    setPosition(tfileio,ttpos)
  end repeat
  
  setPosition(tfileio,tpos)
  writeString(tfileio,copystr(flist.year,1,4))
  ---------------
  tpos=tpos+4
  ttpos=tpos
  repeat with i=1 to 28
    writeChar(tfileio,"")
    ttpos=ttpos+1
    setPosition(tfileio,ttpos)
  end repeat
  setPosition(tfileio,tpos)
  writeString(tfileio,copystr(flist.comment,1,28))
  ---------------
  tpos=tpos+29
  setPosition(tfileio,tpos)
  writeString(tfileio,numtochar(flist.Track))
  ---------------
  tpos=tpos+1
  setPosition(tfileio,tpos)
  writeString(tfileio,numtochar(flist.Genre))
  ---------------
  
  closefile(tfileio)
  tfileio=0
end

--custom functions needed
on copystr fstr,fstart,fend
  if fstart>fend then return ""
  a=fstr.char.count
  tpos=0
  tstr=""
  repeat with i=1 to a
    t=fstr.char[i]
    if chartonum(t)>=10000 then
      tpos=tpos+2
    else if chartonum(t)<999 then
      tpos=tpos+1
    end if
    if tpos>=fstart and tpos<=fend then
      put t after tstr
    end if
  end repeat
  return tstr
end

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail