例子:读取MP3标签
使用这个程序的真实例子是读取MP3文件标签。MP3文件标签存储在最后的128个字节中。本例子包含有一个Director movie,说明是如何做到这一点的(需要FileXtra和FileIO
Xtra)。(关于文件格式,可参考:http://www.wotsit.org)
此例子程序从MP3文件中读取了诸如歌名、歌手、专辑名、年份、风格等信息。
on readMP3tags filePath
fileLength = getFileSizeInBytes (filePath)
if fileLength > 0 then
byteList = readBinaryFile (filePath, fileLength - 127, fileLength)
tagStr = ""
repeat with index = 1 to byteList.count
tagStr = tagStr & numToChar (byteList[index])
end repeat
tags = [#title: tagStr.char[4..33], #artist: tagStr.char[34..63], #album:
tagStr.char[64..93], #year: tagStr.char[94..97], #genre: getGenre (charToNum
(tagStr.char[128]) + 1)]
repeat with index = 1 to tags.count
memberName = string (tags.getPropAt (index))
newText = clipString (tags[index])
member (memberName).text = newText
end repeat
end if
end
|