Working With MP3 Files > Using Server-Side Communication ActionScript

 

Using Server-Side Communication ActionScript

You can use methods of the server-side Stream object to play back an MP3 file (.play) and get the length of an MP3 file (.length). For more information on using these methods with MP3 files, see the Stream.play and Stream.length entries in the Server-Side Communication ActionScript Dictionary.

To delete MP3 files using server-side ActionScript, you can use the Application.clearStreams method. For more information see the Application.clearStreams entry in the Server-Side Communication ActionScript Dictionary.

To publish MP3 files, over a stream, or the ID3 tag information associated with MP3 files, use the Stream.play method, as shown in the following example:

// Set up the server stream
application.myStream = Stream.get( "music" );
if (application.myStream)
{
// Publish the MP3 file bolero.mp3 to the stream "music"
// Use the mp3: prefix in front of the stream name and specify 0 for the startTime parameter to indicate the server should play the recorded stream bolero.mp3
	application.myStream.play("mp3:bolero", 0, -1);
}

To use the Stream.play method to capture and play back the text of ID3 tags, see the following example:

// Set up the server stream
application.myStream = Stream.get( "description" );
application.myStream.onId3 = function(info)
{
	for (i in info)
	{
		trace(i + ": " + info[i]);
	}
}
if (application.myStream)
{
	// Publish the ID3 text tag data of bolero.mp3 to a stream "description".
	// Use the id3: prefix in front of the stream name and specify 0 for the startTime parameter
	application.myStream.play("id3:bolero", 0, -1);
}