JS解析MP3获取歌曲信息--ID3 Reader
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: 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 pictureCOMM/COM: CommentsPCNT/CNT: Play counterT*: Text framesUSLT/ULT: Unsychronized lyric/text transcriptionShortcuts:title: TIT2/TT2artist: TPE1/TP1album: TALB/TALyear: TYER/TYEcomment: COMM/COMtrack: TRCK/TRKgenre: TCON/TCOpicture: APIC/PIClyrics: USLT/ULT
备注:留待再更新编辑
关键字:JavaScript, id3
版权声明
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处。如若内容有涉嫌抄袭侵权/违法违规/事实不符,请点击 举报 进行投诉反馈!