Working with MP3 files
In Flash Media Server applications, you can use client-side ActionScript to play MP3 audio
files and to display the ID3 tags of MP3 files, and use server-side ActionScript to publish
MP3 files over a stream.
To do so, upload the MP3 files for your application to the /streams/application_instance
subdirectory in your registered application directory. (Flash Media Server creates a /streams
subdirectory when you record a stream; if the /streams subdirectory doesn't exist, you can
create it manually.) For example, if you have an application named CDPlayerApp in your
Flash Media Server applications directory, you could upload the MP3 files for that application
to /applications/CDPlayerApp/streams/application_instance.
You can share MP3 files across all instances of an application by placing the shared MP3 files
into a directory and specifying the location of this shared directory as a virtual directory in the
tag in the Vhost.xml file for that application. Then, in your
Streams
statement, specify the virtual directory and the MP3 file you want to play. For information on
virtual directories and the
Flash Media Server.
To play MP3 files, attach a NetStream object to a Video object and call the
or attach it to the MovieClip object and call the
that specifies streamname, or what to play, you must precede the MP3 filename with
The following code sample shows two ways to play the file bolero.mp3 in the network stream
:
mystream
// plays bolero.mp3 in the opened stream mystream_ns, using a Video object
vidObj_video.attachVideo(mystream);
mystream_ns.play("mp3:bolero");
// plays bolero.mp3 in the opened stream mystream2_ns, using a MovieClip
object
// bolero.mp3 is in the directory C:\mp3_files on the Flash Media Server
// computer, which is mapped to the virtual directory mp3dir, in Vhost.xml
movieObj_mc.attachAudio(mystream2_ns);
mystream2_ns.play("mp3:mp3dir/bolero");
In a
NetStream.play()
format, FLV. However, in order to play MP3 files, you must always specify the MP3
format. That is, "flv:granada" and "granada" will both play the file granada.flv but only
"mp3:bolero" will play the file bolero.mp3.
62
Working With Media Files
tag, see "Registering client applications" in Managing
Streams
statement you can choose not to use the default video/audio file
method. In the parameter
attachAudio()
Stream.play()
method,
play()
.
mp3:
Need help?
Do you have a question about the FLASH MEDIA SERVER 2-DEVELOPING MEDIA and is the answer not in the manual?