I’m trying to load the ID3 data for multiple mp3 files with AS3 (AIR app in Flash Builder). It should be able to load data for around a hundred files at a time.
What i want to do is load the ID3 tags for every file, and display the tags on screen when ALL of them have loaded. So i need an event that is somehow dispatched when the ID3 data of all files has loaded, but i can’t figure out how to do that. Right now my code adds a file’s ID3 data to a dictionary as soon as it’s loaded, but how do i know when ALL of the data has loaded?
private function loadSounds(files:Array):void
{
for each (var file:File in files) {
if (file.extension.toLowerCase() == "mp3") {
var mySound:Sound = new Sound(new URLRequest(file.url));
mySound.addEventListener(Event.ID3, ID3handler);
}
}
}
private function ID3handler(event:Event):void {
mySound = event.target as Sound;
if (!dic.hasOwnProperty(mySound.url)) {
dic[mySound.url] = new Array(mySound.id3.artist, mySound.id3.album, mySound.id3.songName);
}
}
(A second problem is that the ID3 event is not always fired. The eventlistener is added, but the function id3Handler isn’t called…)
Can anyone help me with this? I’ve been trying to find a solution for a long time now…