JS解析MP 3は曲情報を取得します.

2861 ワード

ID 3 Readerは、フロントまたはバックグラウンドでMP 3の曲情報を解析できるツールです.
公式のデモのソースコードは全英文の文書をダウンロードします.
使い方の例
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: integer,
    revision: integer,
    flags: {
        unsynchronisation: boolean,
        extended_header: boolean,
        experimental_indicator: boolean
    },
    size: integer,
    *: {
        id: integer,
        size: integer,
        description: string,
        data: 
    },
    *: pointer to .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
備考:編集はまた更新します.