Release and play MP3 files on the FC

Source: Internet
Author: User
Play MP3 files
We know that the default stream playback format in Flash is FLV. However, in applications, you can use the client script to play MP3 audio files and ID3 information, and use the server script to publish the data to the stream.
You need to upload the MP3 file to the/streams/application_instance directory on the server (Macromedia fcs mx 1.5 will automatically create the streams directory when recording the video stream. If it does not exist, you can also manually create it ). For example, if you have a cdplayerapp, you can upload an MP3 file to the/applications/cdplayerapp/streams/application_instance directory.
By setting the shared directory, you can also share MP3 files among other applications.
Find Node, in Add the directory to be shared, such:
Foo; C:/Data
Indicates that all directories containing the foo name will be directed to the C:/data directory. For example, foo/bar will be directed to C:/data/bar. FLV.
For details about vhost. XML, refer to the relevant section in the flashcom Management Manual.
Then, the stream. Play command is used to specify the playing path and the MP3 file to be played. To play MP3 files, we need to use the play method of the netstream object or the attachaudio method of the MC object. Note that, the prefix of the MP3 player ID must be added before the playback file. For more information, see the example code: 1: // non-shared playback.
2: vidobj. attachvideo (mystream );
3: mystream. Play ('mp3: bolero ');
4: // The bolerofiles are stored in the C:/mp3_files directory of the FCS server.
5: // The Directory is mapped to the virtual directory mp3dir in vhost. xml.
6: movieobj. attachaudio (mystream2 );
7: mystream2.play ('mp3: mp3dir/Bolero ');

Tip: if you do not specify the video or audio format when using the netstream. Play method, the default format is FLV. Therefore, you must specify the format for playing MP3. That is to say, FLV: Granada and Granada both play the file Granada. FLV, but MP3: bolerowill only upload the file bolero.pdf. Note that all the files played here are on the server side.

To play ID3 information of an MP3 file, you must use the playback prefix ID3: and define the corresponding callback function to capture ID3 data. For example, the ID3 information of the bolerostrap file is displayed: 1: // displays the ID3 tag of bolerostrap
2: mystream. Play ('id3: Bolero ');
3: // callback function to capture the ID3 data. Data will be displayed
4: // 'info. 'preceding the data from the tag, for example, info. songtitle.
5: mystream. onid3 = function (Info ){
6: For (I in info ){
7: trace (I + ':' + info [I]);
8 :}
9 :}

Supported versions of MP3 ID3 Information
Flashcom Server 1.5 supports UTF-8, UTF-16, and ISO-8859-1 formats 1.0, 2.3 and 2. 4. the version ID3 information, and only supports text data, such as song name, author, remarks, and recording time.

Use server scripts
You can also use the stream object on the server to play MP3 files and obtain the length of MP3 files. For more information, see stream. Play and stream. length in the server script reference.
You can use the application. clearstreams method to delete an MP3 file,
The following example shows how to publish MP3: 01: // set up the server stream through stream. Play.
02: application. mystream = stream. Get ('music ');
03: If (application. mystream)
04 :{
05: // publish the MP3 file bolero=to the stream 'music'
06: // use the MP3: prefix in front of the stream name and specify 0 for
07: starttime parameter to indicate the server shocould play the recorded stream
08: bolerostrap
09: application. mystream. Play ('mp3: bolero', 0,-1 );
10 :}

Use stream. Play to capture and play ID3 information. See the following code example: 01: // set up the server stream
02: application. mystream = stream. Get ('description ');
03: application. mystream. onid3 = function (Info)
04 :{
05: for (I In Info)
06 :{
07: trace (I + ':' + info [I]);
08 :}
09 :}
10: If (application. mystream)
11 :{
12: // publish the ID3 text tag data of bolerostrap to a stream 'description '.
13: // use the ID3: prefix in front of the stream name and specify 0 for
14: starttime Parameter
15: application. mystream. Play ('id3: bolero', 0,-1 );
16 :}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.