1

ID3 Reader 是一款可以在前台或者后台(nodejs)解析MP3曲目信息(前提是含有这些信息)的工具

官方demo 源码下载 全英文文档

用法示例

1,基本用法

//In its simplest form:
ID3.loadTags("filename.mp3", function() {
    var tags = ID3.getAllTags(filename);
    alert(tags.artist + " - " + tags.title + ", " + tags.album);
});

2,特殊用法

//by specifying specific tags:
ID3.loadTags("filename.mp3", function() {
    var tags = ID3.getAllTags(filename);
    alert(tags.COMM.data + " - " + tags.TCON.data + ", " + tags.WXXX.data);
},
{tags: ["COMM", "TCON", "WXXX"]});
//or even by specifying shortcuts instead of cryptic tags:
ID3.loadTags("filename.mp3", function() {
    var tags = ID3.getAllTags(filename);
    alert(tags.comment + " - " + tags.track + ", " + tags.lyrics);
},
{tags: ["comment", "track", "lyrics"]});

3,文档及API

ID3.loadTags(url, cb, [options])//文件路径,回调函数,参数数组

url - The URL of the mp3 file to read, this must reside on the same domain (document.domain).
//文件必须在同域名下

cb - The callback function to invoke when the tags are loaded.
//文件加载完毕后执行

options - Optional parameters.
//参数数组

options.tags - The array of tags and/or shortcuts to read from the ID3 block. Default value is: ["title", "artist", "album", "track"]

options.dataReader - The function used to create the data reader out of a url. It receives (url, success: callback function that returns the data reader, fail: callback function to inform an error setting up the reader). By default it will be BufferedBinaryAjax.
ID3.getAllTags(url)

url - The URL of the mp3 file to read, this must be the same value given to ID3.loadTags().

return value - This function will return the following object structure, for IDv1:
{
    version: "1.1",
    title: string,
    artist: string,
    album: string,
    year: string,
    comment: string,
    track: string,
    genre: string
}

and for ID3v2:

{
    version: "2.<major>.<revision>",
    major: integer,
    revision: integer,
    flags: {
        unsynchronisation: boolean,
        extended_header: boolean,
        experimental_indicator: boolean
    },
    size: integer,
    <frame id>*: {
        id: integer,
        size: integer,
        description: string,
        data: <frame structure>
    },
    <shortcut>*: pointer to <frame id>.data
}
Currently supported frames:

APIC/PIC: Attached picture

COMM/COM: Comments

PCNT/CNT: Play counter

T*: Text frames

USLT/ULT: Unsychronized lyric/text transcription

Shortcuts:

title: TIT2/TT2

artist: TPE1/TP1

album: TALB/TAL

year: TYER/TYE

comment: COMM/COM

track: TRCK/TRK

genre: TCON/TCO

picture: APIC/PIC
lyrics: USLT/ULT

备注:留待再更新编辑


zone
265 声望10 粉丝