Main Page | Packages | Class Tree | Index | Help

mx.controls.streamingmedia

class MP3Player

Object
  |
  +--mx.controls.streamingmedia.AbstractPlayer
        |
        +--mx.controls.streamingmedia.MP3Player

Implemented Interfaces: IPlayer

class MP3Player
extends AbstractPlayer

FLVPlayer contains the logic to play MP3 streaming media files.


Author:
Andrew Guldman


Field Summary

public static
STOP: Number
A constant that indicates that the sound should stop playing once it loads

Fields inherited from class Object

__proto__, constructor, prototype

Properties inherited from class mx.controls.streamingmedia.AbstractPlayer

playing

Constructor

public
MP3Player ( aMediaUrl: String, aSoundHolder: MovieClip)
Constructor.

Method Summary

public
addListener ( aListener: Object ): Void


public
broadcastEvent ( status: String ): Void
The listeners must implement the "handlePlayer" function which takes two parameters: the slider and the current value of the slider.

public
bufferIsFull ( ): Void
These last functions are required by the IPlayer interface but they are not used for MP3 files.

public
close ( ): Void
Close the player.

public
getMediaBytesLoaded ( ): Number


public
getMediaBytesTotal ( ): Number


public
getMediaUrl ( ): String


public
getPlayheadTime ( ): Number


public
getTotalTime ( ): Number
If the mp3 media has not completely loaded, then the duration property of the Sound object is not accurate.

public
getVolume ( ): Number


public
initializeVolume ( ): Void
Set the volume of a new sound to the default volume.

public
isSizeChange ( ): Boolean


public
isSizeSet ( ): Boolean


public
load ( ): Void
Load the media without playing it.

public
logError ( error: String ): Void


public
mediaLoaded ( ): Void
Called when the media is completely loaded.

public
pause ( ): Void
Stop playback of the media without moving the playhead.

public
play ( startingPoint: Number ): Void
Play the media starting at the specified starting point.

public
playStarted ( ): Void
This is called by the MediaDisplay object when playback starts.

public
playStopped ( ): Void


public
removeAllListeners ( ): Void


public
resizeVideo ( ): Void


public
setMediaUrl ( aUrl: String ): Void


public
setPlayheadTime ( aPosition: Number ): Void


public
setSeeking ( isSeeking: Boolean ): Void
For MP3Player, this is a no-op

public
setVolume ( aVol: Number ): Void


public
stop ( ): Void
Stop playback of the media and reset the playhead to zero.

public
willStop ( ): Boolean
This is scoped public so that the MediaDisplay class can access it.

Methods inherited from class mx.controls.streamingmedia.AbstractPlayer

isPlaying, setPlaying

Methods inherited from class Object

addProperty, hasOwnProperty, isPropertyEnumerable, isPrototypeOf, registerClass, toLocaleString, toString, unwatch, valueOf, watch



Field Documentation

STOP

public static var STOP: Number
A constant that indicates that the sound should stop playing once it loads


Constructor Documentation

MP3Player

public function MP3Player(aMediaUrl: String,
 aSoundHolder: MovieClip)
Constructor.


Method Documentation

addListener

public function addListener(aListener: Object): Void
Specified by:
addListener in interface IPlayer

broadcastEvent

public function broadcastEvent(status: String): Void
The listeners must implement the "handlePlayer" function which takes two parameters: the slider and the current value of the slider.

bufferIsFull

public function bufferIsFull(): Void
These last functions are required by the IPlayer interface but they are not used for MP3 files.

Specified by:
bufferIsFull in interface IPlayer

close

public function close(): Void
Close the player.

Specified by:
close in interface IPlayer

getMediaBytesLoaded

public function getMediaBytesLoaded(): Number
Specified by:

Returns:
The number of bytes of the media that has loaded.

getMediaBytesTotal

public function getMediaBytesTotal(): Number
Specified by:

Returns:
The total number of bytes of the media.

getMediaUrl

public function getMediaUrl(): String
Specified by:
getMediaUrl in interface IPlayer

getPlayheadTime

public function getPlayheadTime(): Number
Specified by:

Returns:
The playhead position, measued in seconds since the start.

getTotalTime

public function getTotalTime(): Number
If the mp3 media has not completely loaded, then the duration property of the Sound object is not accurate.

The duration property increases roughly linearly as the media loads. When the media is completely loaded, it is accurate. Hence, we can roughly calculate the total time of an mp3 by scaling the duration by the ratio of bytesTotal/bytesLoaded. In practice, this has been 95+% accurate.

Specified by:
getTotalTime in interface IPlayer

Returns:
The total time of the media in seconds. For mp3 files, this is a property of the Sound object. For video, it is be a property that is manually set by the author.

getVolume

public function getVolume(): Number
Specified by:
getVolume in interface IPlayer

initializeVolume

public function initializeVolume(): Void
Set the volume of a new sound to the default volume.

isSizeChange

public function isSizeChange(): Boolean
Specified by:
isSizeChange in interface IPlayer

isSizeSet

public function isSizeSet(): Boolean
Specified by:
isSizeSet in interface IPlayer

load

public function load(): Void
Load the media without playing it.

Specified by:
load in interface IPlayer

logError

public function logError(error: String): Void
Specified by:
logError in interface IPlayer

mediaLoaded

public function mediaLoaded(): Void
Called when the media is completely loaded.

Specified by:
mediaLoaded in interface IPlayer

pause

public function pause(): Void
Stop playback of the media without moving the playhead.

Specified by:
pause in interface IPlayer

play

public function play(startingPoint: Number): Void
Play the media starting at the specified starting point.

If the media hasn't yet been loaded, load it.

Specified by:
play in interface IPlayer

Parameters:
startingPoint
The number of seconds into the media to start at. This is an optional parameter. If omitted, playing will occur at the current playhead position.

playStarted

public function playStarted(): Void
This is called by the MediaDisplay object when playback starts.

playStopped

public function playStopped(): Void
Specified by:
playStopped in interface IPlayer

removeAllListeners

public function removeAllListeners(): Void
Specified by:

resizeVideo

public function resizeVideo(): Void
Specified by:
resizeVideo in interface IPlayer

setMediaUrl

public function setMediaUrl(aUrl: String): Void
Specified by:
setMediaUrl in interface IPlayer

setPlayheadTime

public function setPlayheadTime(aPosition: Number): Void
Specified by:

Parameters:
aPosition
Time in seconds where the playhead position should be placed

setSeeking

public function setSeeking(isSeeking: Boolean): Void
For MP3Player, this is a no-op

Specified by:
setSeeking in interface IPlayer

setVolume

public function setVolume(aVol: Number): Void
Specified by:
setVolume in interface IPlayer

stop

public function stop(): Void
Stop playback of the media and reset the playhead to zero.

Specified by:
stop in interface IPlayer

willStop

public function willStop(): Boolean
This is scoped public so that the MediaDisplay class can access it.


The documentation was generated from the following file:


Copyright © 1997-2005 Macromedia, Inc. All rights reserved. Generated with AS2Doc