I'm developing a Firefox addon
using the SDK
, which lists audio files on your computer using require("sdk/io/file").list()
.
I build an array of file paths using the method above and pass this array to a contentScript
attached to a Panel
.
The Panel
then loops through the array and displays all the files found.
Now I'm trying to use JavaScript-ID3-Reader so I can read ID3
data from each file and display this data alongside each file.
I've been trying this (read local files), from inside the contentScript
e.g ..
var f = new File([""], "file:///home/user/audio.mp3");
ID3.loadTags("audio.mp3", function () {
var tags = ID3.getAllTags("audio.mp3");
console.log(tags.comment + " - " + tags.track + ", " + tags.lyrics);
}, {
dataReader: FileAPIReader(f)
});
But the output I get is ..
undefined - undefined, undefined
/home/user/audio.mp3
contains the following ID3
data, found with http://web.ist.utl.pt/antonio.afonso/www.aadsm.net/libraries/id3/ ..
Artist
A Perfect Circle
Title
Annihilation
Album
eMOTIVe
Year
2004
Comment
Genre
Pop/Rock
Track
1/12
Lyrics
Here is another test I was trying ..
function getID3 (file) {
var url = file.name;
console.log(url); // console.log: addon: /home/user/audio.mp3
ID3.loadTags(url, function () {
var tags = ID3.getAllTags(url);
console.log(tags); // console.log: addon: {}
console.log(tags.artist); // console.log: addon: null
}, {
dataReader: new FileAPIReader(file)
});
}
var f = new File([""], "file:///home/rob/audio.mp3", {type : "audio/mpeg"});
getID3(f);
Anyone know what might be wrong with this? /home/user/audio.mp3
does exist on file system.
This JavaScript-ID3-Reader library is meant to run in the context of a website, only for files available via http
and https
afaict.
You might want to find a library which will work on the add-on side.