MP3Player
| Kind of class: | class |
|---|---|
| Inherits from: | AbstractPlayer |
| Implements: | |
| Author: | Andrew Guldman |
| Classpath: | mx.controls.streamingmedia.MP3Player |
| File last modified: | Tuesday, 18 December 2007, 15:44:38 |
FLVPlayer contains the logic to play MP3 streaming media files.
Summary
Constructor
- MP3Player (aMediaUrl:String, aSoundHolder:MovieClip)
- Constructor.
Class properties
- STOP : Number
- A constant that indicates that the sound should stop playing once it loads
Instance properties
- _sound : Sound
- _soundHolder : MovieClip
- _mediaUrl : String
- _recentPosition : Number
- # of seconds when the playhead was paused
- _loaded : Boolean
- Has the mp3 been loaded?
- _positionOnLoad : Number
- Position in seconds where the sound should play when it loads.
- _listeners : Array
- _volume : Number
- The current volume setting.
Instance properties inherited from AbstractPlayer
Instance methods
- willStop : Boolean
- This is scoped public so that the MediaDisplay class can access it.
- init
- playStarted : Void
- This is called by the MediaDisplay object when playback starts.
- addListener (aListener:Object) : Void
- removeAllListeners : Void
- broadcastEvent (status:String) : Void
- The listeners must implement the "handlePlayer"
- load : Void
- Load the media without playing it.
- play (startingPoint:Number) : Void
- Play the media starting at the specified starting point.
- pause : Void
- Stop playback of the media without moving the playhead.
- stop : Void
- Stop playback of the media and reset the playhead to zero.
- getPlayheadTime : Number
- setPlayheadTime (aPosition:Number) : Void
- getMediaUrl : String
- setMediaUrl (aUrl:String) : Void
- getVolume : Number
- setVolume (aVol:Number) : Void
- initializeVolume : Void
- Set the volume of a new sound to the default volume.
- getMediaBytesLoaded : Number
- getMediaBytesTotal : Number
- getTotalTime : Number
- If the mp3 media has not completely loaded, then the duration property
- bufferIsFull : Void
- resizeVideo : Void
- playStopped : Void
- mediaLoaded : Void
- Called when the media is completely loaded.
- close : Void
- Close the player.
- logError (error:String) : Void
- isSizeSet : Boolean
- isSizeChange : Boolean
- setSeeking (isSeeking:Boolean) : Void
- For MP3Player, this is a no-op
Instance methods inherited from AbstractPlayer
Constructor
MP3Player
function MP3Player (
aMediaUrl:String,
aSoundHolder:MovieClip)
Constructor.
Class properties
STOP
static STOP:Number = -1
(read)
A constant that indicates that the sound should stop playing once it loads
Instance properties
_listeners
private _listeners:Array
(read)
_loaded
private _loaded:Boolean
(read)
Has the mp3 been loaded?
_mediaUrl
private _mediaUrl:String
(read)
_positionOnLoad
private _positionOnLoad:Number
(read)
Position in seconds where the sound should play when it loads.
STOP indicates that it should not play at all.
STOP indicates that it should not play at all.
_recentPosition
private _recentPosition:Number
(read)
# of seconds when the playhead was paused
_sound
private _sound:Sound
(read)
_soundHolder
private _soundHolder:MovieClip
(read)
_volume
private _volume:Number
(read)
The current volume setting. Used to initialize the volume of new
mp3's that are played.
mp3's that are played.
Instance methods
broadcastEvent
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.
function which takes two parameters: the slider and
the current value of the slider.
getMediaBytesLoaded
function getMediaBytesLoaded (
) : Number
Returns:
- The number of bytes of the media that has loaded.
Specified by:
getMediaBytesTotal
function getMediaBytesTotal (
) : Number
Returns:
- The total number of bytes of the media.
Specified by:
getPlayheadTime
function getPlayheadTime (
) : Number
Returns:
- The playhead position, measued in seconds since the start.
Specified by:
getTotalTime
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.
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.
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.
Specified by:
init
private function init (
)
Initialize the mp3 player.
initializeVolume
function initializeVolume (
) : Void
Set the volume of a new sound to the default volume.
mediaLoaded
function mediaLoaded (
) : Void
Called when the media is completely loaded.
Specified by:
pause
function pause (
) : Void
Stop playback of the media without moving the playhead.
Specified by:
play
function play (
startingPoint:Number) : Void
Play the media starting at the specified starting point. If the media
hasn't yet been loaded, load it.
hasn't yet been loaded, load it.
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.
This is an optional parameter. If omitted, playing will occur
at the current playhead position.
Specified by:
playStarted
function playStarted (
) : Void
This is called by the MediaDisplay object when playback starts.
setPlayheadTime
function setPlayheadTime (
aPosition:Number) : Void
Parameters:
aPosition:
Time in seconds where the playhead position should be placed
setSeeking
function setSeeking (
isSeeking:Boolean) : Void
For MP3Player, this is a no-op
Specified by:
stop
function stop (
) : Void
Stop playback of the media and reset the playhead to zero.
willStop
function willStop (
) : Boolean
This is scoped public so that the MediaDisplay class can access it.