Class mx.controls.streamingmedia.MP3Player

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

Implemented Interfaces

IPlayer

Description

FLVPlayer contains the logic to play MP3 streaming media files.

Field Index

_listeners, _loaded, _mediaUrl, _positionOnLoad, _recentPosition, _sound, _soundHolder, _volume, STOP
Inherited from AbstractPlayer
_playing, playing

Method Index

new MP3Player()

addListener(), broadcastEvent(), bufferIsFull(), close(), getMediaBytesLoaded(), getMediaBytesTotal(), getMediaUrl(), getPlayheadTime(), getTotalTime(), getVolume(), init(), initializeVolume(), isSizeChange(), isSizeSet(), load(), logError(), mediaLoaded(), pause(), play(), playStarted(), playStopped(), removeAllListeners(), resizeVideo(), setMediaUrl(), setPlayheadTime(), setSeeking(), setVolume(), stop(), willStop()
Inherited from AbstractPlayer
isPlaying(), setPlaying()

Constructor Detail

MP3Player

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

Field Detail

STOP

static public STOP:Number

_sound

private _sound:Sound

_soundHolder

private _soundHolder:MovieClip

_mediaUrl

private _mediaUrl:String

_recentPosition

private _recentPosition:Number

_loaded

private _loaded:Boolean

_positionOnLoad

private _positionOnLoad:Number

_listeners

private _listeners:Array

_volume

private _volume:Number

Method Detail

willStop

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

init

private function init()
Initialize the mp3 player.

playStarted

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

addListener

public function addListener(aListener:
Object):Void

removeAllListeners

public function removeAllListeners():Void

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.

load

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

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.
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.

pause

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

stop

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

getPlayheadTime

public function getPlayheadTime():
Number
Return
The playhead position, measued in seconds since the start.

setPlayheadTime

public function setPlayheadTime(aPosition:
Number):Void
Parameters
aPosition Time in seconds where the playhead position should be placed

getMediaUrl

public function getMediaUrl():
String

setMediaUrl

public function setMediaUrl(aUrl:
String):Void

getVolume

public function getVolume():
Number

setVolume

public function setVolume(aVol:
Number):Void

initializeVolume

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

getMediaBytesLoaded

public function getMediaBytesLoaded():
Number
Return
The number of bytes of the media that has loaded.

getMediaBytesTotal

public function getMediaBytesTotal():
Number
Return
The total number of bytes of the media.

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.
Return
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.

bufferIsFull

public function bufferIsFull():Void

resizeVideo

public function resizeVideo():Void

playStopped

public function playStopped():Void

mediaLoaded

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

close

public function close():Void
Close the player.

logError

public function logError(error:
String):Void

isSizeSet

public function isSizeSet():
Boolean

isSizeChange

public function isSizeChange():
Boolean

setSeeking

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