Reading Id3 Tags In Mp3 Files - MACROMEDIA FLASH MX 2004-USING ACTIONSCRIPT IN FLASH Use Manual

Using actionscript in flash
Hide thumbs Also See for FLASH MX 2004-USING ACTIONSCRIPT IN FLASH:
Table of Contents

Advertisement

In most cases, set the
files that should start playing as soon as possible—for example, when creating an MP3 "jukebox"
application. However, if you're downloading shorter sound clips and need to play them at a
specified time (for example, when a user clicks a button), set
To determine when a sound has completely downloaded, use the
This event handler automatically receives a Boolean (
the file downloaded successfully.
For example, suppose you're creating an online game that uses different sounds depending
on what level the user has reached in the game. The following code loads an MP3 file
(blastoff.mp3) into a Sound object named
completely downloaded:
var gameSound:Sound = new Sound();
gameSound.onLoad = function (loadedOK) {
if(loadedOK) {
gameSound.start();
}
}
gameSound.loadSound("http://server.com/sounds/blastoff.mp3", false);
For sound files, Flash Player supports only the MP3 sound file type.
For more information, see
ActionScript Language Reference.

Reading ID3 tags in MP3 files

ID3 tags are data fields added to an MP3 file that contain information about the file, such as the
song name, album name, and artist name.
To read ID3 tags from an MP3 file, use the
the names of ID3 tags included in the MP3 file being loaded. To determine when ID3 tags for a
downloading MP3 file are available, use the
version 1.0, 1.1, 2.3, and 2.4 tags; version 2.2 tags are not supported.
For example, the following code loads an MP3 file named favoriteSong.mp3 into the Sound
object named
song
shows the artist name and song name.
var song:Sound = new Sound();
song.onID3 = function () {
display_txt.text = "Artist: " + song.id3.TPE1 + newline;
display_txt.text += "Song: " + song.id3.TIT2);
}
song.loadSound("mp3s/favoriteSong.mp3", true);
Because ID3 2.0 tags are located at the beginning of an MP3 file (before the sound data), they
are available as soon as the file starts downloading. ID3 1.0 tags, however, are located at the end
of the file (after the sound data), so they aren't available until the entire MP3 file
finishes downloading.
298
Chapter 12: Working with External Media
parameter to
isStreaming
Sound.loadSound()
. When the ID3 tags for the file are available, a text field named
, especially if you're loading large sound
true
isStreaming
or
true
false
, and then plays the sound when it has
gameSound
,
Sound.start()
property, whose properties correspond to
Sound.id3
event handler. Flash Player 7 supports
Sound.onID3
to
.
false
event handler.
Sound.onLoad
) value that indicates whether
, and
in Flash
Sound.onLoad
display_txt

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents