java 读取 id3v2_JS解析MP3获取歌曲信息--ID3 Reader

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

用法示例

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

备注:留待再更新编辑

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值