Packagecom.brightcove.api.components
Classpublic class AudioPlayer
InheritanceAudioPlayer Inheritance Component Inheritance flash.events.EventDispatcher

API class for handing audio playback



Public Properties
 PropertyDefined By
 Inheritedcomponent : Object
[read-only] Returns a reference to the wrapped API element in the player, which can be used to get access to new methods that might not be defined within this version of the SWC.
Component
Public Methods
 MethodDefined By
  
AudioPlayer(element:Object)
Constructor.
AudioPlayer
  
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = true):void
[override] Adds a listener for an event.
AudioPlayer
  
cueMedia(id:Object, property:String = id):Boolean
Cues up an audio track without playing it.
AudioPlayer
 Inherited
getAlpha():Number
Returns the alpha value of the component.
Component
 Inherited
Returns the interface for the layout container of the element.
Component
  
Returns the current audio track DTO in the player.
AudioPlayer
 Inherited
getDefinition():String
Returns the XML (BEML) definition of the component.
Component
 Inherited
getHeight():Number
Returns the pixel height of the component.
Component
 Inherited
getID():String
Returns the ID of the component, as defined in the XML.
Component
 Inherited
Returns whether the component is included in layout calculations and rendering in parent layout box.
Component
 Inherited
getIndex():int
Returns the index of this element in its parent's elements array.
Component
  
For progressively downloaded audio, returns the number of bytes currently loaded for the audio track.
AudioPlayer
  
For progressively downloaded audio, returns the total number of bytes for the current audio track.
AudioPlayer
  
getMediaDuration(format:Boolean = false):Object
Returns the time duration of the currently playing audio track in seconds.
AudioPlayer
  
getMediaPosition(format:Boolean = false):Object
Returns the time position of the currently playing audio track in seconds.
AudioPlayer
 Inherited
Returns the interface for the layout element that is the next sibling to this element in the parent containers's element array.
Component
 Inherited
getNodeName():String
Returns the node name of the element.
Component
 Inherited
Returns the interface for the layout element that is the previous sibling to this element in the parent containers's element array.
Component
  
getSoundSpectrum(fftMode:Boolean = true, stretchFactor:int = 0):ByteArray
ActionScript API only.
AudioPlayer
 Inherited
getVisible():Boolean
Returns whether the component is visible.
Component
  
getVolume():Number
Returns the current volume for audio track playback in the player.
AudioPlayer
 Inherited
getWidth():Number
Returns the pixel width of the component.
Component
 Inherited
getX(global:Boolean = false):Number
Returns the position of the component on the x axis.
Component
 Inherited
getY(global:Boolean = false):Number
Returns the position of the component on the y axis.
Component
  
isMuted():Boolean
Returns whether the audio player currently is muted.
AudioPlayer
  
isPlaying():Boolean
Returns whether the current audio track is playing.
AudioPlayer
  
loadMedia(id:Object, property:String = id):Boolean
Plays an audio track in the player.
AudioPlayer
 Inherited
move(x:Number, y:Number, global:Boolean = false):void
Sets the x,y coordinates of the component.
Component
  
mute(mute:Boolean = true):void
Mutes or unmutes the sound in the player.
AudioPlayer
  
pause(pause:Boolean = true):void
Pauses or resumes playback of the current audio track.
AudioPlayer
  
play():void
Starts playback of the current track in the audio player.
AudioPlayer
  
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
[override] Removes a listener for an event.
AudioPlayer
  
seek(time:Number):void
Seeks to a specified time position in the audio track.
AudioPlayer
 Inherited
setAlpha(alpha:Number):void
Sets the alpha value of the component.
Component
 Inherited
setIncludeInLayout(includeInLayout:Boolean):void
Sets whether the component is included in layout calculations and rendering in parent layout box.
Component
 Inherited
setSize(width:Number, height:Number):void
Sets the pixel dimensions for the wrapped component.
Component
 Inherited
setVisible(visible:Boolean):void
Sets whether the component is visible.
Component
  
setVolume(volume:Number):void
Sets the volume for audio track playback in the player.
AudioPlayer
  
stop():void
Stops playback of the current audio track, sending its position to the start.
AudioPlayer
Protected Methods
 MethodDefined By
  
wrapEvent(event:Event):void
Wraps the internal player event with a wrapper event class.
AudioPlayer
Events
 Event Summary Defined By
 InheritedDispatched when a UI element in the player is clicked.Component
 InheritedDispatched when a UI element in the player is rolled off.Component
 InheritedDispatched when a UI element in the player is rolled over.Component
  Dispatched when media playback first begins.AudioPlayer
  Dispatched when a buffering window begins for the current media, pausing playback.AudioPlayer
  Dispatched when media finishes a buffering window.AudioPlayer
  Dispatched when new media has been loaded or cued in the player.AudioPlayer
  Dispatched when the current media completes.AudioPlayer
  Dispatched when there is an error in loading the media.AudioPlayer
  Dispatched when media's audio is muted or unmuted.AudioPlayer
  Dispatched when media begins or resumes playback.AudioPlayer
  Dispatched as media is played back.AudioPlayer
  Dispatched when media is sent to a new position.AudioPlayer
  Dispatched when media is paused or stopped.AudioPlayer
  Dispatched when the volume in the player is changed.AudioPlayer
 InheritedDispatched when a property changes in a bindable component.Component
Constructor Detail
AudioPlayer()Constructor
public function AudioPlayer(element:Object)

Constructor.

Parameters
element:Object — The layout element to wrap and delegate all calls to.
Method Detail
addEventListener()method
override public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = true):void

Adds a listener for an event.

Parameters

type:String — AS3 docs.
 
listener:Function — AS3 docs.
 
useCapture:Boolean (default = false) — AS3 docs.
 
priority:int (default = 0) — AS3 docs.
 
useWeakReference:Boolean (default = true) — AS3 docs.

cueMedia()method 
public function cueMedia(id:Object, property:String = id):Boolean

Cues up an audio track without playing it. If the audio track is not already loaded into the player, it will be fetched from the server.

Parameters

id:Object — ID or referenceID of the audio track to be cued.
 
property:String (default = id) — the value passed as the first param is an ID or referenceID.

Returns
Boolean — True if the audio track DTO has already been loaded in the player, false if it needs to be fetched.
getCurrentMedia()method 
public function getCurrentMedia():AudioTrackDTO

Returns the current audio track DTO in the player.

Returns
AudioTrackDTO — The current audio track DTO.
getMediaBytesLoaded()method 
public function getMediaBytesLoaded():Number

For progressively downloaded audio, returns the number of bytes currently loaded for the audio track. This can be used to offer the user feedback about download progress.

Returns
Number — The number of bytes downloaded to the client for the current audio track.
getMediaBytesTotal()method 
public function getMediaBytesTotal():Number

For progressively downloaded audio, returns the total number of bytes for the current audio track. This can be used to offer the user feedback about download progress.

Returns
Number — The total number of bytes for the current audio track.
getMediaDuration()method 
public function getMediaDuration(format:Boolean = false):Object

Returns the time duration of the currently playing audio track in seconds.

Parameters

format:Boolean (default = false) — to return a formatted time string (12:34), false to return number of seconds.

Returns
Object — The time duration of the currently playing audio track in seconds, formatted as a string or a number.
getMediaPosition()method 
public function getMediaPosition(format:Boolean = false):Object

Returns the time position of the currently playing audio track in seconds.

Parameters

format:Boolean (default = false) — to return a formatted time string (12:34), false to return number of seconds.

Returns
Object — The time position of the currently playing audio track in seconds, formatted as a string or a number.
getSoundSpectrum()method 
public function getSoundSpectrum(fftMode:Boolean = true, stretchFactor:int = 0):ByteArray

ActionScript API only. Computes the sound spectrum for the current sounds in the player and returns a ByteArray containing this data.

Parameters

fftMode:Boolean (default = true) — Boolean value indicating whether a Fourier transformation is performed on the sound data first.
 
stretchFactor:int (default = 0) — resolution of the sound samples.

Returns
ByteArray — A ByteArray of a fixed length of 512 containing the sound data, 256 for the left channel and and 256 for the right.
getVolume()method 
public function getVolume():Number

Returns the current volume for audio track playback in the player.

Returns
Number — The current volume level of the player.
isMuted()method 
public function isMuted():Boolean

Returns whether the audio player currently is muted.

Returns
Boolean — True if the audio track is muted. False otherwise.
isPlaying()method 
public function isPlaying():Boolean

Returns whether the current audio track is playing.

Returns
Boolean — True if the audio track is playing. False otherwise.
loadMedia()method 
public function loadMedia(id:Object, property:String = id):Boolean

Plays an audio track in the player. If the audio track is not already loaded into the player, it will be fetched from the server.

Parameters

id:Object — ID or referenceID of the audio track to be played.
 
property:String (default = id) — the value passed as the first param is an ID or referenceID.

Returns
Boolean — True if the audio track is in the player and playback is begun.
mute()method 
public function mute(mute:Boolean = true):void

Mutes or unmutes the sound in the player.

Parameters

mute:Boolean (default = true) — to mute the player, false to unmute.

pause()method 
public function pause(pause:Boolean = true):void

Pauses or resumes playback of the current audio track.

Parameters

pause:Boolean (default = true) — a true value will pause the audio track playback. Passing a false value will resume playback.

play()method 
public function play():void

Starts playback of the current track in the audio player.

removeEventListener()method 
override public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void

Removes a listener for an event.

Parameters

type:String — AS3 docs.
 
listener:Function — AS3 docs.
 
useCapture:Boolean (default = false) — AS3 docs.

seek()method 
public function seek(time:Number):void

Seeks to a specified time position in the audio track.

Parameters

time:Number — time in seconds to seek to.

setVolume()method 
public function setVolume(volume:Number):void

Sets the volume for audio track playback in the player.

Parameters

volume:Number — number between 0 and 1 to specify volume level.

stop()method 
public function stop():void

Stops playback of the current audio track, sending its position to the start.

wrapEvent()method 
protected function wrapEvent(event:Event):void

Wraps the internal player event with a wrapper event class.

Parameters

event:Event — event.

Event Detail
mediaBegin Event
Event Object Type: com.brightcove.api.events.MediaEvent
MediaEvent.type property = com.brightcove.api.events.MediaEvent.BEGIN

Dispatched when media playback first begins. This will only occur on initial playback, not on replay.

The MediaEvent.BEGIN constant defines the value of the type property of the event object for a mediaBegin event. BEGIN events are dispatched when media playback first begins. This will only occur on initial playback, not on replay.
mediaBufferBegin Event  
Event Object Type: com.brightcove.api.events.MediaEvent
MediaEvent.type property = com.brightcove.api.events.MediaEvent.BUFFER_BEGIN

Dispatched when a buffering window begins for the current media, pausing playback.

The MediaEvent.BUFFER_BEGIN constant defines the value of the type property of the event object for a mediaBufferBegin event. BUFFER_BEGIN events are dispatched when a buffering window begins for the current media, pausing playback.
mediaBufferComplete Event  
Event Object Type: com.brightcove.api.events.MediaEvent
MediaEvent.type property = com.brightcove.api.events.MediaEvent.BUFFER_COMPLETE

Dispatched when media finishes a buffering window.

The MediaEvent.BUFFER_COMPLETE constant defines the value of the type property of the event object for a mediaBufferComplete event. BUFFER_COMPLETE is dispatched when media finishes a buffering window.
mediaChange Event  
Event Object Type: com.brightcove.api.events.MediaEvent
MediaEvent.type property = com.brightcove.api.events.MediaEvent.CHANGE

Dispatched when new media has been loaded or cued in the player.

The MediaEvent.CHANGE constant defines the value of the type property of the event object for a mediaChange event. CHANGE is dispatched when new media has been loaded or cued in the player.
mediaComplete Event  
Event Object Type: com.brightcove.api.events.MediaEvent
MediaEvent.type property = com.brightcove.api.events.MediaEvent.COMPLETE

Dispatched when the current media completes. This only occurs on initial playback of media, not on replay.

The MediaEvent.COMPLETE constant defines the value of the type property of the event object for a mediaComplete event. COMPLETE events are dispatched when the current media finishes. This only occurs on initial playback of media, not on replay.
mediaError Event  
Event Object Type: com.brightcove.api.events.MediaEvent
MediaEvent.type property = com.brightcove.api.events.MediaEvent.ERROR

Dispatched when there is an error in loading the media.

The MediaEvent.ERROR constant defines the value of the type property of the event object for a mediaError event. ERROR is dispatched when there is a problem connecting to or playing the current media.
mediaMuteChange Event  
Event Object Type: com.brightcove.api.events.MediaEvent
MediaEvent.type property = com.brightcove.api.events.MediaEvent.MUTE_CHANGE

Dispatched when media's audio is muted or unmuted.

The MediaEvent.MUTE_CHANGE constant defines the value of the type property of the event object for a mediaMuteChange event. MUTE_CHANGE is dispatched when media's audio is muted or unmuted.
mediaPlay Event  
Event Object Type: com.brightcove.api.events.MediaEvent
MediaEvent.type property = com.brightcove.api.events.MediaEvent.PLAY

Dispatched when media begins or resumes playback.

The MediaEvent.PLAY constant defines the value of the type property of the event object for a mediaPlay event. PLAY is dispatched when media begins or resumes playback.
mediaProgress Event  
Event Object Type: com.brightcove.api.events.MediaEvent
MediaEvent.type property = com.brightcove.api.events.MediaEvent.PROGRESS

Dispatched as media is played back.

The MediaEvent.PROGRESS constant defines the value of the type property of the event object for a mediaProgress event. PROGRESS is dispatched periodically while media is being played back.
mediaSeek Event  
Event Object Type: com.brightcove.api.events.MediaEvent
MediaEvent.type property = com.brightcove.api.events.MediaEvent.SEEK

Dispatched when media is sent to a new position.

The MediaEvent.SEEK constant defines the value of the type property of the event object for a seek event. SEEK is dispatched when media is requested to be sent to a new position.
mediaStop Event  
Event Object Type: com.brightcove.api.events.MediaEvent
MediaEvent.type property = com.brightcove.api.events.MediaEvent.STOP

Dispatched when media is paused or stopped.

The MediaEvent.STOP constant defines the value of the type property of the event object for a mediaStop event. STOP events are dispatched when media is paused or stopped.
mediaVolumeChange Event  
Event Object Type: com.brightcove.api.events.MediaEvent
MediaEvent.type property = com.brightcove.api.events.MediaEvent.VOLUME_CHANGE

Dispatched when the volume in the player is changed.

The MediaEvent.VOLUME_CHANGE constant defines the value of the type property of the event object for a mediaVolumeChange event. VOLUME_CHANGE is dispatched when the volume in the player is changed.