Packagecv.media
Classpublic class AudioManager
InheritanceAudioManager Inheritance flash.events.EventDispatcher
ImplementsIMediaManager

The AudioManager class is a facade for controlling loading, and playing of MP3 files within Flash. It intelligently handles pausing, mute and loading.

See also

cv.interfaces.IMediaManager


Public Properties
 PropertyDefined by
  buffer : int
Gets or sets how long AudioManager should buffer the audio before playing, in seconds.
AudioManager
  currentPercent : uint
[read-only] Gets the current play progress in terms of percent
AudioManager
  isPause : Boolean
[read-only] If AudioManager is currently paused.
AudioManager
  isPlaying : Boolean
[read-only] If AudioManager is currently playing.
AudioManager
  loadCurrent : Number
[read-only] Gets the current load progress in terms of bytes
AudioManager
  loadTotal : Number
[read-only] Gets the total size to be loaded in terms of bytes
AudioManager
  metaData : Object
[read-only] Gets the metadata if available for the currently playing audio file
AudioManager
  timeCurrent : Number
[read-only] Gets the elapsed play time in milliseconds
AudioManager
  timeLeft : Number
[read-only] Gets the remaining play time in milliseconds
AudioManager
  timeTotal : Number
[read-only] Gets the total play time in milliseconds
AudioManager
  volume : Number
Gets or sets the current volume, from 0 - 1
AudioManager
Public Methods
 MethodDefined by
  
AudioManager
  
isValid(str:String):Boolean
Validates if the given filetype is compatible to be played with AudioManager.
AudioManager
  
load(s:String):void
Loads a new file to be played.
AudioManager
  
mute(b:Boolean = true):void
Controls the mute of the audio
AudioManager
  
pause(b:Boolean = true):void
Controls the pause of the audio
AudioManager
  
play(pos:int = 0):void
Plays the audio, starting at the given position.
AudioManager
  
seek(n:Number):void
Seeks to time given in the audio.
AudioManager
  
seekPercent(n:Number):void
Seeks to the given percent in the audio
AudioManager
  
stop(pos:int = 0):void
Stops the audio at the specified position.
AudioManager
  
unLoad():void
Stops the audio, closes the sound class, and resets the metadata.
AudioManager
Events
 EventSummaryDefined by
   Dispatched as ID3 metadata is receieved from an MP3 AudioManager
   Dispatched when the media file has completed loading AudioManager
   Dispatched as a media file is loaded AudioManager
   Dispatched as a media file begins loading AudioManager
   Dispatched after AudioManager has begun loading the next item, also at the end of an item playing AudioManager
   Dispatched as a media file finishes playing AudioManager
   Dispatched as a media file is playing AudioManager
   Dispatched once as a media file first begins to play AudioManager
Property detail
bufferproperty
buffer:int  [read-write]

Gets or sets how long AudioManager should buffer the audio before playing, in seconds.

Implementation
    public function get buffer():int
    public function set buffer(value:int):void
currentPercentproperty 
currentPercent:uint  [read-only]

Gets the current play progress in terms of percent

Implementation
    public function get currentPercent():uint
isPauseproperty 
isPause:Boolean  [read-only]

If AudioManager is currently paused.

Implementation
    public function get isPause():Boolean
isPlayingproperty 
isPlaying:Boolean  [read-only]

If AudioManager is currently playing.

Implementation
    public function get isPlaying():Boolean
loadCurrentproperty 
loadCurrent:Number  [read-only]

Gets the current load progress in terms of bytes

Implementation
    public function get loadCurrent():Number
loadTotalproperty 
loadTotal:Number  [read-only]

Gets the total size to be loaded in terms of bytes

Implementation
    public function get loadTotal():Number
metaDataproperty 
metaData:Object  [read-only]

Gets the metadata if available for the currently playing audio file

Implementation
    public function get metaData():Object
timeCurrentproperty 
timeCurrent:Number  [read-only]

Gets the elapsed play time in milliseconds

Implementation
    public function get timeCurrent():Number
timeLeftproperty 
timeLeft:Number  [read-only]

Gets the remaining play time in milliseconds

Implementation
    public function get timeLeft():Number
timeTotalproperty 
timeTotal:Number  [read-only]

Gets the total play time in milliseconds

Implementation
    public function get timeTotal():Number
volumeproperty 
volume:Number  [read-write]

Gets or sets the current volume, from 0 - 1

Implementation
    public function get volume():Number
    public function set volume(value:Number):void
Constructor detail
AudioManager()constructor
public function AudioManager()
Method detail
isValid()method
public function isValid(str:String):Boolean

Validates if the given filetype is compatible to be played with AudioManager. The only acceptable type is 'mp3'.

Parameters
str:String — The file extension to be validated

Returns
Boolean — Boolean of whether the extension was valid or not.
load()method 
public function load(s:String):void

Loads a new file to be played.

Parameters
s:String — The url of the file to be loaded

See also

cv.events.LoadEvent.LOAD_START
mute()method 
public function mute(b:Boolean = true):void

Controls the mute of the audio

Parameters
b:Boolean (default = true) — Whether to mute or not
pause()method 
public function pause(b:Boolean = true):void

Controls the pause of the audio

Parameters
b:Boolean (default = true) — Whether to pause or not
play()method 
public function play(pos:int = 0):void

Plays the audio, starting at the given position.

Parameters
pos:int (default = 0) — Position to play from
seek()method 
public function seek(n:Number):void

Seeks to time given in the audio.

Parameters
n:Number — Seconds into the audio to seek to
seekPercent()method 
public function seekPercent(n:Number):void

Seeks to the given percent in the audio

Parameters
n:Number — Percent to seek to
stop()method 
public function stop(pos:int = 0):void

Stops the audio at the specified position. Sets the position given as the pause position.

Parameters
pos:int (default = 0) — Position to stop at
unLoad()method 
public function unLoad():void

Stops the audio, closes the sound class, and resets the metadata.

Event detail
audioMetadataevent 
Event object type: cv.events.MetaDataEvent
MetaDataEvent.type property = cv.events.MetaDataEvent.AUDIO_METADATA

Dispatched as ID3 metadata is receieved from an MP3

Defines the value of the type property of an audioMetadata event object.

This event has the following properties:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
dataThe metadata object.
currentTargetThe object that is actively processing the event object with an event listener.
targetThe object that dispatched the event. The target is not always the object listening for the event. Use the currentTarget property to access the object that is listening for the event.
loadCompleteevent  
Event object type: flash.events.Event

Dispatched when the media file has completed loading

loadProgressevent  
Event object type: flash.events.ProgressEvent

Dispatched as a media file is loaded

loadStartevent  
Event object type: cv.LoadEvent

Dispatched as a media file begins loading

nextevent  
Event object type: flash.events.Event

Dispatched after AudioManager has begun loading the next item, also at the end of an item playing

playCompleteevent  
Event object type: flash.events.Event

Dispatched as a media file finishes playing

playProgressevent  
Event object type: cv.events.PlayProgressEvent
PlayProgressEvent.type property = cv.events.PlayProgressEvent.PLAY_PROGRESS

Dispatched as a media file is playing

Defines the value of the type property of an playProgress event object.

This event has the following properties:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
percentThe percentage of progress for the media playing.
elapsedThe elapsed time of the media playing.
remainThe remaining time of the media playing.
totalThe total time of the media playing.
currentTargetThe object that is actively processing the event object with an event listener.
targetThe object that dispatched the event. The target is not always the object listening for the event. Use the currentTarget property to access the object that is listening for the event.
playStartevent  
Event object type: flash.events.Event

Dispatched once as a media file first begins to play