答案 0 :(得分:5)
另外还有一个图书馆 https://github.com/aadsm/JavaScript-ID3-Reader
最简单的形式:
ID3.loadTags("filename.mp3", function() {
var tags = ID3.getAllTags(filename);
alert(tags.artist + " - " + tags.title + ", " + tags.album);
});
指定特定标签:
ID3.loadTags("filename.mp3", function() {
var tags = ID3.getAllTags(filename);
alert(tags.COMM.data + " - " + tags.TCON.data + ", " + tags.WXXX.data);
},
{tags: ["COMM", "TCON", "WXXX"]});
甚至通过指定快捷方式而不是隐藏标签:
ID3.loadTags("filename.mp3", function() {
var tags = ID3.getAllTags(filename);
alert(tags.comment + " - " + tags.track + ", " + tags.lyrics);
},
{tags: ["comment", "track", "lyrics"]});
在这里演示http://web.ist.utl.pt/antonio.afonso/www.aadsm.net/libraries/id3/#demo
答案 1 :(得分:2)
看起来你可以使用正确的库! Reading ID3 tags with Javascript和here is the demo
使用ID3.js库,您的Javascript类似于:
// URL of the mp3 file (must be on the same domain!)
var file = "mymusicfile.mp3";
// define your own callback function
function mycallback() {
// either call the ID3.getAllTags([file]) function which returns an object holding all the tags
alert(
"All tags in this file: " + ID3.getAllTags(file).toSource()
);
// or call ID3.getTag([file], [tag]) to get a specific tag
alert(
"Title: " + ID3.getTag(file, "title") + " by artist: " + ID3.getTag(file, "artist")
);
}
ID3.loadTags(file, mycallback);
基于我提供的第一个链接中的帖子,它在Opera浏览器中不起作用,仅限于ID3v1,用海报的话说:
“它只能读取(相当缺乏的)ID3v1标签,因为与更加丰富且功能强大的ID3v2标签相比,它们非常简单”