The Flash Communication Server API Tools
The Flash Communication Server API (Application Program Interface) gives you a set of objects, methods, and commands that you can use to develop applications that use the Client, the Server, or an integration of both.
The client-side API, located within the Macromedia Flash MX authoring environment, deploys the NetStream object, its methods, and its properties to make it possible for you to publish, control, and play MP3 files. Using this object, you can write application logic directly into the application (the movie file) or to *.as files. You can deploy the .as files within your application with the #include method. In this tutorial, you will write the application logic directly into the movie.
The server-side API uses the Stream object and its methods and properties to make it possible for you to publish, control, and play of MP3 files. Your application logic writes to the main.asc file and deploys within your application folder in the applications directory on the Flash Communication Server.
Storing and Retrieving MP3 Files and Data
Flash Communication Server provides two main options for storing and retrieving of your MP3 files and the data they contain. The communication server supports retrieving and playback of ID3 tags—but only text data playback such as song titles and artist names.
Option 1: Streams folder: Flash Communication Server loads your MP3 files into the application/streams/applications_instance folder. This is similar to the way the Flash Communication Server creates a streams subdirectory when it records a stream. If there is no stream folder within the application folder, you can manually create one. It is very important that you create an applications_instance folder within the streams folder; without the folder you will not have access to the MP3 files. Therefore, you will have an application called myMP3_library and your MP3 files should load with a mapping similar to the following:
applications/myMP3_library/streams/my_personal_MP3
Option 2: Virtual directory: Another way to store and
access your MP3 files is through a virtual directory. Create a virtual
directory by writing a route map to the location of the folder holding
the MP3 files. Write the location map of the required folder to the <Streams>
tag in the Vhost.xml doc to set up the virtual directory. You can find
the Vhost.xml file in the conf directory in the setup files for Flash
Communication Server 1.5.
The server mapping in the Vhost.xml file lets any application developed
on that server access MP3 files. By specifying the virtual directory,
you can use the server Stream or Client NetStream play()
method to get the MP3 file you want. A typical virtual directory mapping
looks like this:
<Streams>mpGroove;d:/Nu_Music/tuff_music</Streams>
Note: The folder delimiter must be a forward slash ("/").
Any application can access MP3 files located in the root folderD:/Nu_Music/tuff_music)
by using the play() method, as follows:
Mp3_ns.play(mp3:mpGroove/music_file_name)
Two Scenarios for Implementing MP3 Streaming
To see how you use all of this information, read about the process of creating two applications. The first application, an online MP3 library, uses the client-side NetStream methods to access and play stored MP3 files. The other application is a mini Macromedia Flash web station that uses the server-side Stream object with the client-side NetStream object to stream MP3 sound and data to all connected clients.