Packagecv
Classpublic class TempoLite
InheritanceTempoLite Inheritance flash.display.Sprite

Version:

2.0.3

Date:

10/24/2008

Updates At:

http://blog.coursevector.com/tempolite

TempoLite is based off of its sister project Tempo this is a parsed down version that does not handle a UI. TempoLite is best compared with players like video.Maru, in the sense that it’s just a component that is dragged on stage and handles all of the media playback. This allows for a UI as complicated as you want to make it while the actually playback is handled by TempoLite.

Coded By:

Gabriel Mariani, gabriel[at]coursevector.com
Copyright 2008, Course Vector (This work is subject to the terms in http://blog.coursevector.com/?page_id=24.)

Notes:



Example
Show example here



Public Properties
 PropertyDefined by
  autoStart : Boolean
Whether a video will play immediately when a playlist is loaded.
TempoLite
  autoStartIndex : int
If autoStart is true, the index of the item in the playlist to play first.
TempoLite
  bufferTime : int
The time in seconds to buffer a file before playing.
TempoLite
  isPause : Boolean
[read-only] If TempoLite is currently paused.
TempoLite
  isPlaying : Boolean
[read-only]
TempoLite
  length : uint
[read-only] Retrieves the number of items in the playlist.
TempoLite
  repeat : String
Sets whether repeat is enabled, or which type of repeat is enabled.
TempoLite
  shuffle : Boolean
Whether to shuffle the playlist or not.
TempoLite
  version : String
[static][read-only] The version of TempoLite in use.
TempoLite
  volume : Number
A number from 0 to 1 determines volume.
TempoLite
Protected Properties
 PropertyDefined by
  aM : IMediaManager
TempoLite
  cM : IMediaManager
TempoLite
  plM : PlayListManager
TempoLite
  screenHeight : Number
TempoLite
  screenWidth : Number
TempoLite
  screenX : Number
TempoLite
  screenY : Number
TempoLite
  vidScreen : Video
TempoLite
  vM : IMediaManager
TempoLite
Public Methods
 MethodDefined by
  
Constructor.
TempoLite
  
addItem(item:Object, index:int = -1):void
Add an item to the playlist at the end, or at index specified.
TempoLite
  
clearItems():void
Clears the current playlist.
TempoLite
  
Retrieve the current index in the playlist.
TempoLite
  
getCurrentItem():Object
Retrieve the current item playing.
TempoLite
  
Retrieve the current play progress as a percent.
TempoLite
  
Retrieve the current playlist in PlayList format (enhanced array).
TempoLite
  
getLoadCurrent():Number
Retrieve the current bytes loaded of the current item.
TempoLite
  
getLoadTotal():Number
Retrieve the total bytes to load of the current item.
TempoLite
  
getMetaData():Object
Retrieve the metadata from the current item playing if available.
TempoLite
  
Retrieve the current play time of the current item playing.
TempoLite
  
Retrieve the play time remaining of the current item playing.
TempoLite
  
Retrieve the total play time of the current item playing.
TempoLite
  
loadMedia(item:Object, autoStart:Boolean = true):void
Create a playlist of a single item and load the item.
TempoLite
  
loadPlayList(url:String = "playlists/Tempo.m3u"):void
Loads a new playlist and clears any previous playlsit.
TempoLite
  
next():void
Plays the next item in the playlist.
TempoLite
  
pause(b:Boolean = true):void
Pauses the current playback.
TempoLite
  
play(index:int = -1):void
Plays the current item in the playlist, or at the specified index in the playlist.
TempoLite
  
previous():void
Plays the previous item in the playlist.
TempoLite
  
removeItem(index:int = -1):void
Remove an item from the playlist from the end, or at index specified.
TempoLite
  
seek(time:Number):void
Seek to a specific time (in seconds) in the current item playing.
TempoLite
  
seekPercent(percent:Number):void
Seek to a specific percent (0 - 1) in the current item playing.
TempoLite
  
seekRelative(time:Number):void
Seek by the amount (in seconds) specified relative to the current play time.
TempoLite
  
setMute(b:Boolean):void
Toggles mute.
TempoLite
  
setStreamHost(value:String):void
Used to specify a hosting server when streaming video
TempoLite
  
setVideoScale(scaleMode:String):void
Determines how TempoLite will scale a video.
TempoLite
  
setVideoScreen(video:Video):void
Assigns a video screen for TempoLite to display videos with.
TempoLite
  
stop():void
Stops the selected item in the playlist.
TempoLite
  
stringToTime(text:String):int
Converts a time in 00:00:000 format and converts it back into a number.
TempoLite
  
timeToString(n:int):String
Converts milliseconds to a 00:00:000 format.
TempoLite
  
unloadMedia():void
Unloads the current item playing.
TempoLite
Protected Methods
 MethodDefined by
  
eventHandler(e:Event):void
TempoLite
  
TempoLite
  
load(o:Object):void
TempoLite
  
TempoLite
  
playlistHandler(e:Event):void
TempoLite
  
zero(n:int, isMS:Boolean = false):String
TempoLite
Events
 EventSummaryDefined by
   Dispatched as ID3 metadata is receieved from an MP3 TempoLite
   Dispatched from the PlayList when a change has occured TempoLite
   Dispatched everytime a cue point is encountered TempoLite
   Dispatched as a media file is loaded TempoLite
   Dispatched as a media file begins loading TempoLite
   Dispatched after Tempo has begun loading the next item, also at the end of an item playing TempoLite
   Dispatched as a media file finishes playing TempoLite
   Dispatched as a media file is playing TempoLite
   Dispatched once as a media file first begins to play TempoLite
   Dispatched after Tempo has begun loading the previous item TempoLite
   Dispatched from the PlayListManager when ever an item is removed, or updated, or the entire list is updated TempoLite
   Dispatched as metadata is receieved from an video stream of M4A file TempoLite
Public Constants
 ConstantDefined by
  AUDIO : String = "audio"
[static]
TempoLite
  AUDIO_METADATA : String = "audioMetadata"
[static]
TempoLite
  CHANGE : String = "change"
[static]
TempoLite
  EXACT_FIT : String = "fit"
[static]
TempoLite
  LOAD_COMPLETE : String = "loadComplete"
[static]
TempoLite
  LOAD_PROGRESS : String = "loadProgress"
[static]
TempoLite
  LOAD_START : String = "loadStart"
[static]
TempoLite
  MAINTAIN_ASPECT_RATIO : String = "ratio"
[static]
TempoLite
  NEW_PLAYLIST : String = "newPlaylist"
[static]
TempoLite
  NEXT : String = "next"
[static]
TempoLite
  NO_SCALE : String = "scale"
[static]
TempoLite
  PLAY_COMPLETE : String = "playComplete"
[static]
TempoLite
  PLAY_PROGRESS : String = "playProgress"
[static]
TempoLite
  PLAY_START : String = "playStart"
[static]
TempoLite
  PREVIOUS : String = "prev"
[static]
TempoLite
  REFRESH_PLAYLIST : String = "refreshPlaylist"
[static]
TempoLite
  REPEAT_ALL : String = "all"
[static]
TempoLite
  REPEAT_NONE : String = "none"
[static]
TempoLite
  REPEAT_TRACK : String = "track"
[static]
TempoLite
  VERSION : String = "2.0.3"
[static] The current version of TempoLite in use.
TempoLite
  VIDEO : String = "video"
[static]
TempoLite
  VIDEO_METADATA : String = "videoMetadata"
[static]
TempoLite
Property detail
aMproperty
protected var aM:IMediaManager
autoStartproperty 
autoStart:Boolean  [read-write]

Whether a video will play immediately when a playlist is loaded.

Implementation
    public function get autoStart():Boolean
    public function set autoStart(value:Boolean):void
autoStartIndexproperty 
autoStartIndex:int  [read-write]

If autoStart is true, the index of the item in the playlist to play first.

Implementation
    public function get autoStartIndex():int
    public function set autoStartIndex(value:int):void
bufferTimeproperty 
bufferTime:int  [read-write]

The time in seconds to buffer a file before playing.

Implementation
    public function get bufferTime():int
    public function set bufferTime(value:int):void
cMproperty 
protected var cM:IMediaManager
isPauseproperty 
isPause:Boolean  [read-only]

If TempoLite is currently paused.

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

Retrieves the number of items in the playlist.

Implementation
    public function get length():uint
plMproperty 
protected var plM:PlayListManager
repeatproperty 
repeat:String  [read-write]

Sets whether repeat is enabled, or which type of repeat is enabled. Accepted values are:

  • TempoLite.REPEAT_ALL
  • TempoLite.REPEAT_TRACK
  • TempoLite.REPEAT_NONE
  • Implementation
        public function get repeat():String
        public function set repeat(value:String):void
    screenHeightproperty 
    protected var screenHeight:Number
    screenWidthproperty 
    protected var screenWidth:Number
    screenXproperty 
    protected var screenX:Number
    screenYproperty 
    protected var screenY:Number
    shuffleproperty 
    shuffle:Boolean  [read-write]

    Whether to shuffle the playlist or not.

    The default value is false.

    Implementation
        public function get shuffle():Boolean
        public function set shuffle(value:Boolean):void
    versionproperty 
    version:String  [read-only]

    The version of TempoLite in use.

    Implementation
        public static function get version():String
    vidScreenproperty 
    protected var vidScreen:Video
    vMproperty 
    protected var vM:IMediaManager
    volumeproperty 
    volume:Number  [read-write]

    A number from 0 to 1 determines volume.

    The default value is 0.5.

    Implementation
        public function get volume():Number
        public function set volume(value:Number):void
    Constructor detail
    TempoLite()constructor
    public function TempoLite()

    Constructor.

    This creates a new TempoLite instance.

    Method detail
    addItem()method
    public function addItem(item:Object, index:int = -1):void

    Add an item to the playlist at the end, or at index specified.

    Parameters
    item:Object — item to be added.
     
    index:int (default = -1) — where the item should be added in the playlist.
    clearItems()method 
    public function clearItems():void

    Clears the current playlist.

    eventHandler()method 
    protected function eventHandler(e:Event):voidParameters
    e:Event
    getCurrentIndex()method 
    public function getCurrentIndex():uint

    Retrieve the current index in the playlist.

    Returns
    uint — the index of the playlist.
    getCurrentItem()method 
    public function getCurrentItem():Object

    Retrieve the current item playing.

    Returns
    Object — the current item playing.
    getCurrentPercent()method 
    public function getCurrentPercent():uint

    Retrieve the current play progress as a percent.

    Returns
    uint — the play progress in terms of percent.
    getList()method 
    public function getList():PlayList

    Retrieve the current playlist in PlayList format (enhanced array).

    Returns
    PlayList — the playlist as a PlayList type.
    getLoadCurrent()method 
    public function getLoadCurrent():Number

    Retrieve the current bytes loaded of the current item.

    Returns
    Number — the current bytes loaded of the item.
    getLoadTotal()method 
    public function getLoadTotal():Number

    Retrieve the total bytes to load of the current item.

    Returns
    Number — the total bytes to load of the item.
    getMetaData()method 
    public function getMetaData():Object

    Retrieve the metadata from the current item playing if available.

    Returns
    Object — the metadata associated with the item playing.
    getTimeCurrent()method 
    public function getTimeCurrent():int

    Retrieve the current play time of the current item playing.

    Returns
    int — the current play time of the item playing.
    getTimeLeft()method 
    public function getTimeLeft():int

    Retrieve the play time remaining of the current item playing.

    Returns
    int — the play time remaining of the item playing.
    getTimeTotal()method 
    public function getTimeTotal():int

    Retrieve the total play time of the current item playing.

    Returns
    int — the total play time of the item playing.
    initMedia()method 
    protected function initMedia(m:IMediaManager):voidParameters
    m:IMediaManager
    load()method 
    protected function load(o:Object):voidParameters
    o:Object
    loadMedia()method 
    public function loadMedia(item:Object, autoStart:Boolean = true):void

    Create a playlist of a single item and load the item.

    Parameters
    item:Object — item to be played.
     
    autoStart:Boolean (default = true) — Whether the file will start playing as soon as possible
    loadPlayList()method 
    public function loadPlayList(url:String = "playlists/Tempo.m3u"):void

    Loads a new playlist and clears any previous playlsit.

    Parameters
    url:String (default = "playlists/Tempo.m3u") — the path to the playlist file.
    metaDataHandler()method 
    protected function metaDataHandler(e:MetaDataEvent):voidParameters
    e:MetaDataEvent
    next()method 
    public function next():void

    Plays the next item in the playlist.

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

    Pauses the current playback.

    Parameters
    b:Boolean (default = true) — Value to set pause to
    play()method 
    public function play(index:int = -1):void

    Plays the current item in the playlist, or at the specified index in the playlist.

    Parameters
    index:int (default = -1) — The index of the item to be played
    playlistHandler()method 
    protected function playlistHandler(e:Event):voidParameters
    e:Event
    previous()method 
    public function previous():void

    Plays the previous item in the playlist.

    See also

    removeItem()method 
    public function removeItem(index:int = -1):void

    Remove an item from the playlist from the end, or at index specified.

    Parameters
    index:int (default = -1) — The index of the item to be removed
    seek()method 
    public function seek(time:Number):void

    Seek to a specific time (in seconds) in the current item playing.

    Parameters
    time:Number — Specific time to seek to, in seconds
    seekPercent()method 
    public function seekPercent(percent:Number):void

    Seek to a specific percent (0 - 1) in the current item playing.

    Parameters
    percent:Number — Percentage to seek to
    seekRelative()method 
    public function seekRelative(time:Number):void

    Seek by the amount (in seconds) specified relative to the current play time.

    Parameters
    time:Number — Amount to seek relative to current play time in seconds.
    setMute()method 
    public function setMute(b:Boolean):void

    Toggles mute.

    Parameters
    b:Boolean — Value to set mute to
    setStreamHost()method 
    public function setStreamHost(value:String):void

    Used to specify a hosting server when streaming video

    Parameters
    value:String — The host url

    Example
    import cv.TempoLite;

    var vidScreen:Video = new Video();
    this.addChild(vidScreen);

    var tempo:TempoLite = new TempoLite();
    tempo.setStreamHost("rtmp://cp11111.edgefcs.net/ondemand");
    tempo.loadMedia({url:"11111/VideoName", extOverride:"flv"});
    tempo.setVideoScreen(vidScreen);

    setVideoScale()method 
    public function setVideoScale(scaleMode:String):void

    Determines how TempoLite will scale a video. The options are

    Parameters
    scaleMode:String — scale mode to use for video scaling.

    See also

    setVideoScreen()method 
    public function setVideoScreen(video:Video):void

    Assigns a video screen for TempoLite to display videos with.

    Parameters
    video:Video — video display object to be used as a screen.
    stop()method 
    public function stop():void

    Stops the selected item in the playlist.

    stringToTime()method 
    public function stringToTime(text:String):int

    Converts a time in 00:00:000 format and converts it back into a number.

    Parameters
    text:String — The string to convert

    Returns
    int — The converted number
    timeToString()method 
    public function timeToString(n:int):String

    Converts milliseconds to a 00:00:000 format.

    Parameters
    n:int — Milliseconds to convert

    Returns
    String — The converted string
    unloadMedia()method 
    public function unloadMedia():void

    Unloads the current item playing.

    zero()method 
    protected function zero(n:int, isMS:Boolean = false):StringParameters
    n:int
     
    isMS:Boolean (default = false)

    Returns
    String
    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.
    changeevent  
    Event object type: flash.events.Event

    Dispatched from the PlayList when a change has occured

    cuePointevent  
    Event object type: cv.events.CuePointEvent
    CuePointEvent.type property = cv.events.CuePointEvent.CUE_POINT

    Dispatched everytime a cue point is encountered

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

    This event has the following properties:

    PropertyValue
    bubblesfalse
    cancelablefalse; there is no default behavior to cancel.
    cuePointThe cue point 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.
    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 Tempo 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

    previousevent  
    Event object type: flash.events.Event

    Dispatched after Tempo has begun loading the previous item

    refreshPlaylistevent  
    Event object type: flash.events.Event

    Dispatched from the PlayListManager when ever an item is removed, or updated, or the entire list is updated

    videoMetadataevent  
    Event object type: cv.events.MetaDataEvent
    MetaDataEvent.type property = cv.events.MetaDataEvent.VIDEO_METADATA

    Dispatched as metadata is receieved from an video stream of M4A file

    Defines the value of the type property of an videoMetadata 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.
    Constant detail
    AUDIOconstant
    public static const AUDIO:String = "audio"
    AUDIO_METADATAconstant 
    public static const AUDIO_METADATA:String = "audioMetadata"
    CHANGEconstant 
    public static const CHANGE:String = "change"
    EXACT_FITconstant 
    public static const EXACT_FIT:String = "fit"
    LOAD_COMPLETEconstant 
    public static const LOAD_COMPLETE:String = "loadComplete"
    LOAD_PROGRESSconstant 
    public static const LOAD_PROGRESS:String = "loadProgress"
    LOAD_STARTconstant 
    public static const LOAD_START:String = "loadStart"
    MAINTAIN_ASPECT_RATIOconstant 
    public static const MAINTAIN_ASPECT_RATIO:String = "ratio"
    NEW_PLAYLISTconstant 
    public static const NEW_PLAYLIST:String = "newPlaylist"
    NEXTconstant 
    public static const NEXT:String = "next"
    NO_SCALEconstant 
    public static const NO_SCALE:String = "scale"
    PLAY_COMPLETEconstant 
    public static const PLAY_COMPLETE:String = "playComplete"
    PLAY_PROGRESSconstant 
    public static const PLAY_PROGRESS:String = "playProgress"
    PLAY_STARTconstant 
    public static const PLAY_START:String = "playStart"
    PREVIOUSconstant 
    public static const PREVIOUS:String = "prev"
    REFRESH_PLAYLISTconstant 
    public static const REFRESH_PLAYLIST:String = "refreshPlaylist"
    REPEAT_ALLconstant 
    public static const REPEAT_ALL:String = "all"
    REPEAT_NONEconstant 
    public static const REPEAT_NONE:String = "none"
    REPEAT_TRACKconstant 
    public static const REPEAT_TRACK:String = "track"
    VERSIONconstant 
    public static const VERSION:String = "2.0.3"

    The current version of TempoLite in use.

    VIDEOconstant 
    public static const VIDEO:String = "video"
    VIDEO_METADATAconstant 
    public static const VIDEO_METADATA:String = "videoMetadata"