Old Articles - 6 years, 4 months ago - 0 Comments
Accessing ID3 Tags (external .mp3)
In Flash MX you have the capability to load an external mp3 sound file into a flash movie using the Sound.loadSound() method. In the latest release of the Flash 6 Player it is possible to access the ID3 tags embedded in an mp3 encoded file. Unfortuneatley you cannot access the ID3 tags in an mp3 file until it has *fully* loaded, this is fine when you are using the Sound.attachSound() method but it causes problems when you are loading an external sound into the player...
When an external sound has fully loaded into the player, you have to wait one frame before you can retrieve the values of the ID3 tags in the mp3. This means that you cannot access the ID3 tags inside of the Sound objects onLoad event handler. Here is some code that demonstrates how to access the ID3 tags from an external mp3 file loaded into the player using the Sound.loadSound() method:
-
//create an onEnterFrame event with
-
//listener capabilities
-
ASBroadcaster.initialize(Movieclip);
-
_root.createEmptyMovieClip('__enterFrame',-9799);
-
__enterFrame.onEnterFrame=function(){
-
Movieclip.broadcastMessage('onEnterFrame');
-
}
-
mysound=new Sound(this);
-
mysound.loadSound('an_mp3.mp3');
-
mysound.onLoad=function(){
-
Movieclip.addListener(this);
-
//redefine the onLoad event handler
-
this.onLoad=function(){
-
//iterate over all the id3 tags
-
//and trace their names and values
-
for(var i in this.id3){
-
trace(i+':'+this.id3[i]);
-
}
-
}
-
//when the onEnterFrame broadcast
-
//is recieved, call the newly defined
-
//onLoad evet handler and then
-
//stop listening to the broadcast
-
this.onEnterFrame=function(){
-
this.onLoad();
-
Movieclip.removeListener(this);
-
delete this.onEnterFrame;
-
}
-
}
The same is true, for two other properties of the sound object, Sound.duration and Sound.position, you cannot access these properties until one frame after an external sound file has fully loaded, you can use the same process outlined above to retrieve the value of these two properties.
Note: This is an old article!
Please be aware that the content of this article may no longer be accurate and the links contained within could be broken.
Update Notifications
You can add our RSS feed to your favorite feed reader or recieve an email when a new article is posted by entering your email address below.
FLASH EXPERTS
- Andre Michelle
- Aral Balkan
- Big Spaceship
- Chafic Kazoun
- Colin Moock
- Craig Swann
- Erik Natzke
- Grant Skinner
- Jesse Warden
- John Grden
- Keith Peters
- Lee Brimelow
- Lord Alex
- Mario Kingemann
- Matt Voermn
- Ralph Hauwert
- Richard Leggett
- Trevor McCauley
FLASH COMPONENTS
- AFComponents
- Components Network
- Extend Studio
- Flash Relief
- Flash Store
- Flashden
- Flashloaded
- Ghostwire
- Image Vue
- Jumpeye
- Page Flip Component
- Slideshowpro
FLASH VIDEO
- Akamai
- FFMPEG
- FlashComGuru
- Flashstreamworks
- FLV Player
- FLVMDI
- flvPlayerPro
- FLVTool2
- Influxis
- JW FLV Player
- Vital Stream
FLASH RESOURCES
- Actionscript.org
- Adobe Labs
- Developer Center
- Flash Interface
- Flash Player Statistics
- Flashkit
- Kirupa
- MDM Zinc
- OSFlash
- PaperVision3D
- SWXFormat
- Tweener
SPONSORS
More In Actionscript
- Adobe MAKE SOME NOISE
- Undocumented Actionscript 3
- BitmapData.loadBitmap gone in AS3
- Actionscript 3 - New Capabilities
- Flash 8 - setTimeout

