Packagecv.media
Classpublic class NetStreamPlayer
InheritanceNetStreamPlayer Inheritance flash.events.EventDispatcher
ImplementsIMediaPlayer
SubclassesRTMPPlayer

Version:

3.0.2

Date:

4/02/2009

Updates At:

http://blog.coursevector.com/tempolite

The NetStreamPlayer class is a facade for controlling loading, and playing of video, streaming video and M4A files within Flash. It intelligently handles pausing, and loading. Note: Sometimes playhead won't move on videos, this is because there is no metadata describing it's duration. If this occurs, there is no way to calculate how long a video is, so it stops the playhead from moving.



Public Properties
 PropertyDefined by
  autoRewind : Boolean = false
Will automatically call stop (rewind) after playing complete.
NetStreamPlayer
  autoScale : Boolean = false
Gets or sets whether the video object will be scaled to the metadata given for video dimensions.
NetStreamPlayer
  autoStart : Boolean
Whether media will play automatically once loaded.
NetStreamPlayer
  buffer : int
Gets or sets how long the NetStreamPlayer should buffer the video before playing, in seconds.
NetStreamPlayer
  currentPercent : uint
[read-only] Gets the current play progress in terms of percent
NetStreamPlayer
  debug : Boolean = false
NetStreamPlayer
  leftToLeft : Number
A value, from 0 (none) to 1 (all), specifying how much of the left input is played in the left speaker.
NetStreamPlayer
  leftToRight : Number
A value, from 0 (none) to 1 (all), specifying how much of the left input is played in the right speaker.
NetStreamPlayer
  loadCurrent : uint
[read-only] Gets the current load progress in terms of bytes
NetStreamPlayer
  loadTotal : uint
[read-only] Gets the total size to be loaded in terms of bytes
NetStreamPlayer
  metaData : Object
[read-only] Gets the metadata if available for the currently playing audio file
NetStreamPlayer
  pan : Number
The left-to-right panning of the sound, ranging from -1 (full pan left) to 1 (full pan right).
NetStreamPlayer
  paused : Boolean
[read-only] Returns the pause status of the player.
NetStreamPlayer
  rightToLeft : Number
A value, from 0 (none) to 1 (all), specifying how much of the right input is played in the left speaker.
NetStreamPlayer
  rightToRight : Number
A value, from 0 (none) to 1 (all), specifying how much of the right input is played in the right speaker.
NetStreamPlayer
  status : String
[read-only] Returns the load status of the player.
NetStreamPlayer
  timeCurrent : Number
[read-only] Gets the elapsed play time in milliseconds
NetStreamPlayer
  timeLeft : Number
[read-only] Gets the remaining play time in milliseconds
NetStreamPlayer
  timeTotal : Number
[read-only] Gets the total play time in milliseconds
NetStreamPlayer
  video : Video
Gets or sets the reference to the display video object.
NetStreamPlayer
  volume : Number
Gets or sets the current volume, from 0 - 1
NetStreamPlayer
Protected Properties
 PropertyDefined by
  arrFileTypes : Array
NetStreamPlayer
  _autoStart : Boolean = true
NetStreamPlayer
  _buffer : Number = 0.1
NetStreamPlayer
  client : Object
NetStreamPlayer
  _encoding : uint = 0
NetStreamPlayer
  _leftToLeft : Number = 1
NetStreamPlayer
  _leftToRight : Number = 0
NetStreamPlayer
  _loadCurrent : uint
NetStreamPlayer
  loadTimer : Timer
NetStreamPlayer
  _loadTotal : uint
NetStreamPlayer
  _metaData : Object
NetStreamPlayer
  nc : NetConnection
NetStreamPlayer
  ns : NetStream
NetStreamPlayer
  _pan : Number = 0
NetStreamPlayer
  _paused : Boolean = false
NetStreamPlayer
  playTimer : Timer
NetStreamPlayer
  _rightToLeft : Number = 0
NetStreamPlayer
  _rightToRight : Number = 1
NetStreamPlayer
  sendOnce : Boolean = false
NetStreamPlayer
  skipOnce : Boolean = false
NetStreamPlayer
  _status : String = "unloaded"
NetStreamPlayer
  _streamHost : String = "null"
NetStreamPlayer
  strURL : String
NetStreamPlayer
  vid : Video
NetStreamPlayer
  _volume : Number = .5
NetStreamPlayer
Public Methods
 MethodDefined by
  
NetStreamPlayer
  
isValid(ext:String, url:String):Boolean
Validates if the given filetype is compatible to be played with NetStreamPlayer.
NetStreamPlayer
  
load(item:*):void
Loads a new file to be played.
NetStreamPlayer
  
pause(b:Boolean = true):void
Loads a netstream from the BulkLoader to be played.
NetStreamPlayer
  
play(pos:int = 0):void
Plays the media, starting at the given position.
NetStreamPlayer
  
seek(time:*):void
Seeks to time given in the media.
NetStreamPlayer
  
seekPercent(n:Number):void
Seeks to the given percent in the media
NetStreamPlayer
  
stop():void
Stops the media at the specified position.
NetStreamPlayer
  
unload():void
Stops the media, closes the NetConnetion or NetStream, and resets the metadata.
NetStreamPlayer
Protected Methods
 MethodDefined by
  
createConnection(command:String = null):void
NetStreamPlayer
  
createStream(netstream:NetStream = null):void
NetStreamPlayer
  
errorHandler(e:ErrorEvent):void
NetStreamPlayer
  
NetStreamPlayer
  
loadTimerHandler(event:TimerEvent):void
NetStreamPlayer
  
netStatusHandler(e:NetStatusEvent):void
NetStreamPlayer
  
onCuePoint(o:Object):void
NetStreamPlayer
  
onMetaData(o:Object):void
Handles the metadata returned.
NetStreamPlayer
  
playTimerHandler(event:TimerEvent):void
NetStreamPlayer
  
setStatus(str:String):void
NetStreamPlayer
  
trace2(... arguements):void
NetStreamPlayer
  
NetStreamPlayer
  
NetStreamPlayer
Events
 EventSummaryDefined by
   Dispatched when a cue point is reached.NetStreamPlayer
   Dispatched when the media file has completed loading NetStreamPlayer
   Dispatched as a media file is loaded NetStreamPlayer
   Dispatched as a media file begins loading NetStreamPlayer
   Dispatched as metadata is receieved from the media playing NetStreamPlayer
   Dispatched as a media file finishes playing NetStreamPlayer
   Dispatched as a media file is playing NetStreamPlayer
   Dispatched once as a media file first begins to play NetStreamPlayer
   Dispatched when isPause or isPlaying has updated.NetStreamPlayer
Public Constants
 ConstantDefined by
  VERSION : String = "3.0.2"
[static] The current version
NetStreamPlayer
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.

autoScaleproperty 
public var autoScale:Boolean = false

Gets or sets whether the video object will be scaled to the metadata given for video dimensions.

_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
_bufferproperty 
protected var _buffer:Number = 0.1
bufferproperty 
buffer:int  [read-write]

Gets or sets how long the NetStreamPlayer should buffer the video before playing, in seconds.

Implementation
    public function get buffer():int
    public function set buffer(value:int):void
clientproperty 
protected var client:Object
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
_encodingproperty 
protected var _encoding:uint = 0
_leftToLeftproperty 
protected var _leftToLeft:Number = 1
leftToLeftproperty 
leftToLeft:Number  [read-write]

A value, from 0 (none) to 1 (all), specifying how much of the left input is played in the left speaker.

Implementation
    public function get leftToLeft():Number
    public function set leftToLeft(value:Number):void
_leftToRightproperty 
protected var _leftToRight:Number = 0
leftToRightproperty 
leftToRight:Number  [read-write]

A value, from 0 (none) to 1 (all), specifying how much of the left input is played in the right speaker.

Implementation
    public function get leftToRight():Number
    public function set leftToRight(value:Number):void
_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
loadTimerproperty 
protected var loadTimer:Timer
_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
ncproperty 
protected var nc:NetConnection
nsproperty 
protected var ns:NetStream
_panproperty 
protected var _pan:Number = 0
panproperty 
pan:Number  [read-write]

The left-to-right panning of the sound, ranging from -1 (full pan left) to 1 (full pan right). A value of 0 represents no panning (balanced center between right and left).

Implementation
    public function get pan():Number
    public function set pan(value:Number):void
_pausedproperty 
protected var _paused:Boolean = false
pausedproperty 
paused:Boolean  [read-only]

Returns the pause status of the player.

Implementation
    public function get paused():Boolean
playTimerproperty 
protected var playTimer:Timer
_rightToLeftproperty 
protected var _rightToLeft:Number = 0
rightToLeftproperty 
rightToLeft:Number  [read-write]

A value, from 0 (none) to 1 (all), specifying how much of the right input is played in the left speaker.

Implementation
    public function get rightToLeft():Number
    public function set rightToLeft(value:Number):void
_rightToRightproperty 
protected var _rightToRight:Number = 1
rightToRightproperty 
rightToRight:Number  [read-write]

A value, from 0 (none) to 1 (all), specifying how much of the right input is played in the right speaker.

Implementation
    public function get rightToRight():Number
    public function set rightToRight(value:Number):void
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
_streamHostproperty 
protected var _streamHost:String = "null"
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 
timeTotal:Number  [read-only]

Gets the total play time in milliseconds

Implementation
    public function get timeTotal():Number
vidproperty 
protected var vid:Video
videoproperty 
video:Video  [read-write]

Gets or sets the reference to the display video object.

Implementation
    public function get video():Video
    public function set video(value:Video):void
_volumeproperty 
protected var _volume:Number = .5
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
NetStreamPlayer()constructor
public function NetStreamPlayer()
Method detail
createConnection()method
protected function createConnection(command:String = null):voidParameters
command:String (default = null)
createStream()method 
protected function createStream(netstream:NetStream = null):voidParameters
netstream:NetStream (default = null)
errorHandler()method 
protected function errorHandler(e:ErrorEvent):voidParameters
e:ErrorEvent
getEstimatedLength()method 
protected function getEstimatedLength():int

Returns
int
isValid()method 
public function isValid(ext:String, url:String):Boolean

Validates if the given filetype is compatible to be played with NetStreamPlayer. 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:*
loadTimerHandler()method 
protected function loadTimerHandler(event:TimerEvent):voidParameters
event:TimerEvent
netStatusHandler()method 
protected function netStatusHandler(e:NetStatusEvent):voidParameters
e:NetStatusEvent
onCuePoint()method 
protected function onCuePoint(o:Object):voidParameters
o:Object
onMetaData()method 
protected function onMetaData(o:Object):void

Handles the metadata returned. Possible data sent:

  • canSeekToEnd
  • cuePoints
  • audiocodecid
  • audiodelay
  • audiodatarate
  • videocodecid
  • framerate
  • videodatarate
  • height - Older version of encode
  • width - Older version of encode
  • duration - Older version of encode
  • Parameters
    o:Object
    pause()method 
    public function pause(b:Boolean = true):void

    Loads a netstream from the BulkLoader to be played. This cannot be used in conjunction with TempoLite since the location is not a url. Using loadAsset will IGNORE any streamhosts set becuase you can only use this if the video is progressively downloaded.

    Parameters
    b:Boolean (default = true) — The netstream object from the BulkLoader

    See also

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

    Plays the media, starting at the given position.

    Parameters
    pos:int (default = 0) — Position to play from

    See also

    cv.events.PlayProgressEvent.PLAY_PROGRESS
    playTimerHandler()method 
    protected function playTimerHandler(event:TimerEvent):voidParameters
    event:TimerEvent
    seek()method 
    public function seek(time:*):void

    Seeks to time given in the media.

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

    See also

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

    Seeks to the given percent in the media

    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 media at the specified position. Sets the position given as the pause position.

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

    Stops the media, closes the NetConnetion or NetStream, and resets the metadata.

    See also

    cv.events.PlayProgressEvent.STATUS
    updateProgress()method 
    protected function updateProgress():void
    updateSoundTransform()method 
    protected function updateSoundTransform():void
    Event detail
    cuePointevent 
    Event object type: cv.events.MetadataEvent

    Dispatched when a cue point is reached.

    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
    LoadEvent.type property = cv.events.LoadEvent.LOAD_START

    Dispatched as a media file begins loading

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

    This event has the following properties:

    Property Value
    bubbles false
    cancelablefalse; there is no default behavior to cancel.
    timeThe estimated duration of the media file.
    urlTThe url of the item being loaded.
    currentTargetThe object that is actively processing the event object with an event listener.
    indexThe zero-based index in the DataProvider that contains the renderer.
    itemA reference to the data that belongs to the renderer.
    mediaTypeThe type of media being loaded, either "audio" or "video".
    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.
    metadataevent  
    Event object type: cv.events.MetaDataEvent
    MetaDataEvent.type property = cv.events.MetaDataEvent.METADATA

    Dispatched as metadata is receieved from the media playing

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

    Dispatched when isPause or isPlaying has updated.

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

    The current version