Reading ID3 tags with JavaScript

19 August 2008, 8:27 am

Jacob Seidelin is up to more tricks, this time playing with the binary side of life and writing a library that can reading ID3 tags from MP3 files and such. PLAIN TEXT 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);   You can view a demo at work or download the code. Of course, Jacob realises that this doesn't make sense for many use cases: Of course, one big disadvantage of doing this on the client in JavaScript is that the you need to download the entire MP3 file before the tags are available, so it might be better to stick to server-side solutions in many cases if all you need is the tag info. ... read more

Featured Photos

Featured Video