7.5. Streaming MP3 AudioOne of the additions to FlashCom 1.5 from the original 1.0 release is the capability to stream MP3 audio files from a FlashCom application. Now, you may be scratching your head, thinking, "Can't I already load MP3 files into the Flash Player with Sound.loadSound( ) ?" And you're right. However, loadSound( ) operates with HTTP, and so requires that the MP3 files (or source) are accessible from a web server. Also, it's possible for someone to discover this source and access the MP3 files directly, without the use of Flash Player. With FlashCom, you can protect your MP3 sources and be fairly confident that the right to access those files is managed. Just like FLV files, MP3 files streamed with FlashCom over RTMP (or HTTP tunneling) are never cached as whole files on the end user 's computer. The MP3 data is stored only temporarily as chunks within the Flash Player's buffer. After the sound has played , there's nothing left over on the user's machine. Because of this security feature, you may decide to use FlashCom Server as your MP3 streaming server as well as your video streaming server. For a review of stream basics and an introduction to MP3 streaming, including use of the NetStream and Stream classes, refer to Chapter 5. 7.5.1. Considerations for MP3 PlaybackUnlike the FLV format, the MP3 audio format is very popular and widely accessible. There are more MP3 audio converters than you can shake a stick at, and many of them are freely available on http://www.download.com. Apple iTunes includes a free MP3 encoder, with several customizable compression options. Like the Sorenson Spark codec, the MP3 audio codec has two primary encoding methods : CBR (constant bit rate) or VBR (variable bit rate). While VBR encoding takes a bit longer to complete, the better audio quality is worth the wait. In our experience, FlashCom can stream just about any MP3 file you want to stream. If you are going to encode a batch of files in the MP3 format with the hope of streaming them on FlashCom, you should create a few test files with your preferred encoder and compression options to use with a sample FlashCom application. Once you know your flavor of MP3 files works with FlashCom, proceed to encode the rest of the files in the same manner. 7.5.2. Using the MediaPlayback Component to Play MP3 FilesIn this section, you learn how to create a list of MP3 sound effects and play them with the MediaPlayback component that ships with Flash Pro. Download the following Zip file containing four MP3 files:
Once you have downloaded the Zip file, uncompress the MP3 files ( dog.mp3 , cat.mp3 , bird.mp3 , duck.mp3 ) and move them to the following application path on your FlashCom Server:
If you haven't created the main.asc for the broadcast application as discussed in the previous section, review the "Configuring the FCS Application" section for more details. Now that you have the MP3 files ready to stream from your FlashCom Server, you're ready to build the user interface in Flash Pro:
|