Packagecv.media
Classpublic class ImagePlayer
InheritanceImagePlayer Inheritance flash.display.Sprite
ImplementsIMediaPlayer

Version:

1.0.2

Date:

4/02/2009

Updates At:

http://blog.coursevector.com/tempolite

The ImagePlayer class is a facade for controlling loading, and playing of images.



Public Properties
 PropertyDefined by
  autoRewind : Boolean = false
Will automatically call stop (rewind) after playing complete.
ImagePlayer
  autoStart : Boolean
Whether media will play automatically once loaded.
ImagePlayer
  currentPercent : uint
[read-only] Gets the current play progress in terms of percent
ImagePlayer
  debug : Boolean = false
Enables/Disables debug traces
ImagePlayer
  loadCurrent : uint
[read-only] Gets the current load progress in terms of bytes
ImagePlayer
  loadTotal : uint
[read-only] Gets the total size to be loaded in terms of bytes
ImagePlayer
  metaData : Object
[read-only] Gets the metadata if available for the currently playing audio file
ImagePlayer
  paused : Boolean
[read-only] Returns the pause status of the player.
ImagePlayer
  status : String
[read-only] Returns the load status of the player.
ImagePlayer
  timeCurrent : Number
[read-only] Gets the elapsed play time in milliseconds
ImagePlayer
  timeLeft : Number
[read-only] Gets the remaining play time in milliseconds
ImagePlayer
  timeTotal : Number
[read-only] Gets the total play time in milliseconds
ImagePlayer
  volume : Number
Gets or sets the current volume, from 0 - 1
ImagePlayer
Protected Properties
 PropertyDefined by
  arrFileTypes : Array
ImagePlayer
  _autoStart : Boolean = true
ImagePlayer
  ldr : Loader
ImagePlayer
  _loadCurrent : uint
ImagePlayer
  _loadTotal : uint
ImagePlayer
  _metaData : Object
ImagePlayer
  _paused : Boolean = false
ImagePlayer
  pausePosition : int = 0
ImagePlayer
  playInterval : uint
ImagePlayer
  position : int = 0
ImagePlayer
  sendOnce : Boolean = false
ImagePlayer
  skipOnce : Boolean = false
ImagePlayer
  _status : String = "unloaded"
ImagePlayer
  strURL : String
ImagePlayer
  _timeTotal : Number
ImagePlayer
  _volume : Number
ImagePlayer
Public Methods
 MethodDefined by
  
ImagePlayer
  
isValid(ext:String, url:String):Boolean
Validates if the given filetype is compatible to be played with ImagePlayer.
ImagePlayer
  
load(item:*):void
Loads a new file to be played.
ImagePlayer
  
pause(b:Boolean = true):void
Pauses the media
ImagePlayer
  
play(pos:int = 0):void
Starts playback at the given position.
ImagePlayer
  
seek(time:*):void
Seeks to time given.
ImagePlayer
  
seekPercent(n:Number):void
Seeks to the given percent
ImagePlayer
  
stop():void
Stops the image at the specified position.
ImagePlayer
  
unload():void
Unloads the image and resets the metadata.
ImagePlayer
Protected Methods
 MethodDefined by
  
errorHandler(e:ErrorEvent):void
ImagePlayer
  
imageHandler(e:Event):void
ImagePlayer
  
progressHandler(e:ProgressEvent):void
ImagePlayer
  
setStatus(str:String):void
ImagePlayer
  
timeHandler():void
ImagePlayer
  
trace2(... arguements):void
ImagePlayer
Events
 EventSummaryDefined by
   Dispatched when the media file has completed loading ImagePlayer
   Dispatched as a media file is loaded ImagePlayer
   Dispatched as a media file begins loading ImagePlayer
   Dispatched after images loads.ImagePlayer
   Dispatched as a media file finishes playing ImagePlayer
   Dispatched as a media file is playing ImagePlayer
   Dispatched once as a media file first begins to play ImagePlayer
   Dispatched when status has been updated.ImagePlayer
Public Constants
 ConstantDefined by
  VERSION : String = "1.0.2"
[static] The current version
ImagePlayer
Property detail
arrFileTypesproperty
protected var arrFileTypes:Array
autoRewindproperty 
public var autoRewind:Boolean = false

Will automatically call stop (rewind) after playing complete. If disabled, this will pause the player instead.

_autoStartproperty 
protected var _autoStart:Boolean = true
autoStartproperty 
autoStart:Boolean  [read-write]

Whether media will play automatically once loaded.

The default value is true.

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

Gets the current play progress in terms of percent

Implementation
    public function get currentPercent():uint
debugproperty 
public var debug:Boolean = false

Enables/Disables debug traces

ldrproperty 
protected var ldr:Loader
_loadCurrentproperty 
protected var _loadCurrent:uint
loadCurrentproperty 
loadCurrent:uint  [read-only]

Gets the current load progress in terms of bytes

Implementation
    public function get loadCurrent():uint
_loadTotalproperty 
protected var _loadTotal:uint
loadTotalproperty 
loadTotal:uint  [read-only]

Gets the total size to be loaded in terms of bytes

Implementation
    public function get loadTotal():uint
_metaDataproperty 
protected var _metaData:Object
metaDataproperty 
metaData:Object  [read-only]

Gets the metadata if available for the currently playing audio file

Implementation
    public function get metaData():Object
_pausedproperty 
protected var _paused:Boolean = false
pausedproperty 
paused:Boolean  [read-only]

Returns the pause status of the player.

Implementation
    public function get paused():Boolean
pausePositionproperty 
protected var pausePosition:int = 0
playIntervalproperty 
protected var playInterval:uint
positionproperty 
protected var position:int = 0
sendOnceproperty 
protected var sendOnce:Boolean = false
skipOnceproperty 
protected var skipOnce:Boolean = false
_statusproperty 
protected var _status:String = "unloaded"
statusproperty 
status:String  [read-only]

Returns the load status of the player.

Implementation
    public function get status():String
strURLproperty 
protected var strURL:String
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 
protected var _timeTotal:Number
timeTotalproperty 
timeTotal:Number  [read-only]

Gets the total play time in milliseconds

Implementation
    public function get timeTotal():Number
_volumeproperty 
protected var _volume: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
ImagePlayer()constructor
public function ImagePlayer()
Method detail
errorHandler()method
protected function errorHandler(e:ErrorEvent):voidParameters
e:ErrorEvent
imageHandler()method 
protected function imageHandler(e:Event):voidParameters
e:Event
isValid()method 
public function isValid(ext:String, url:String):Boolean

Validates if the given filetype is compatible to be played with ImagePlayer. The acceptable file types are :

Parameters
ext:String — The file extension to be validated
 
url:String — The full file url if the extension is not enough

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

Loads a new file to be played.

Parameters
item:* — The url of the file to be loaded

See also

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

Pauses the media

Parameters
b:Boolean (default = true) — Whether to pause or toggle it off

See also

cv.events.PlayProgressEvent.STATUS
cv.events.PlayProgressEvent.PLAY_PROGRESS
play()method 
public function play(pos:int = 0):void

Starts playback at the given position.

Parameters
pos:int (default = 0) — Position to play from
progressHandler()method 
protected function progressHandler(e:ProgressEvent):voidParameters
e:ProgressEvent
seek()method 
public function seek(time:*):void

Seeks to time given.

Parameters
time:* — Seconds into the audio to seek to

See also

cv.events.PlayProgressEvent.PLAY_PROGRESS
seekPercent()method 
public function seekPercent(n:Number):void

Seeks to the given percent

Parameters
n:Number — Percent to seek to

See also

cv.events.PlayProgressEvent.PLAY_PROGRESS
setStatus()method 
protected function setStatus(str:String):voidParameters
str:String
stop()method 
public function stop():void

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

timeHandler()method 
protected function timeHandler():void
trace2()method 
protected function trace2(... arguements):voidParameters
... arguements
unload()method 
public function unload():void

Unloads the image and resets the metadata.

See also

cv.events.PlayProgressEvent.STATUS
Event detail
loadCompleteevent 
Event object type: cv.events.LoadEvent
LoadEvent.type property = cv.events.LoadEvent.LOAD_COMPLETE

Dispatched when the media file has completed loading

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

loadProgressevent  
Event object type: flash.events.ProgressEvent
ProgressEvent.type property = cv.events.LoadEvent.LOAD_PROGRESS

Dispatched as a media file is loaded

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

loadStartevent  
Event object type: cv.events.LoadEvent

Dispatched as a media file begins loading

metadataevent  
Event object type: cv.events.MetaDataEvent
MetaDataEvent.type property = cv.events.MetaDataEvent.METADATA

Dispatched after images loads. Contains height and width of image.

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.
playCompleteevent  
Event object type: cv.events.PlayProgressEvent

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: cv.events.PlayProgressEvent

Dispatched once as a media file first begins to play

statusevent  
Event object type: flash.events.Event

Dispatched when status has been updated.

Constant detail
VERSIONconstant
public static const VERSION:String = "1.0.2"

The current version