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.
- 3.0.2
- Tweaked how load complete reports
- loadCurrent and loadTotal are now uints and more accurate
- 3.0.1
- Changed how PLAY_START and autoStart is handled. autoStart is no longer overwritten and will pause before any audio is heard.
- Handles autostart and PLAY_START better. Also has a new status of STARTED to differentiate between when autoStart and the first play().
- Added autoRewind prop. If set, it will rewind after PLAY_COMPLETE so the play button can be used to resume.
- 3.0.0
protected var arrFileTypes:Array
public var autoRewind:Boolean = false
Will automatically call stop (rewind) after playing complete. If disabled, this will pause
the player instead.
public var autoScale:Boolean = false
Gets or sets whether the video object will be scaled to the metadata given
for video dimensions.
protected var _autoStart:Boolean = true
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
protected var _buffer:Number = 0.1
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
protected var client:Object
currentPercent:uint
[read-only]
Gets the current play progress in terms of percent
Implementation
public function get currentPercent():uint
public var debug:Boolean = false
protected var _encoding:uint = 0
protected var _leftToLeft:Number = 1
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
protected var _leftToRight:Number = 0
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
protected var _loadCurrent:uint
loadCurrent:uint
[read-only]
Gets the current load progress in terms of bytes
Implementation
public function get loadCurrent():uint
protected var loadTimer:Timer
protected var _loadTotal:uint
loadTotal:uint
[read-only]
Gets the total size to be loaded in terms of bytes
Implementation
public function get loadTotal():uint
protected var _metaData:Object
metaData:Object
[read-only]
Gets the metadata if available for the currently playing audio file
Implementation
public function get metaData():Object
protected var nc:NetConnection
protected var ns:NetStream
protected var _pan:Number = 0
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
protected var _paused:Boolean = false
paused:Boolean
[read-only]
Returns the pause status of the player.
Implementation
public function get paused():Boolean
protected var playTimer:Timer
protected var _rightToLeft:Number = 0
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
protected var _rightToRight:Number = 1
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
protected var sendOnce:Boolean = false
protected var skipOnce:Boolean = false
protected var _status:String = "unloaded"
status:String
[read-only]
Returns the load status of the player.
Implementation
public function get status():String
protected var _streamHost:String = "null"
protected var strURL:String
timeCurrent:Number
[read-only]
Gets the elapsed play time in milliseconds
Implementation
public function get timeCurrent():Number
timeLeft:Number
[read-only]
Gets the remaining play time in milliseconds
Implementation
public function get timeLeft():Number
timeTotal:Number
[read-only]
Gets the total play time in milliseconds
Implementation
public function get timeTotal():Number
protected var vid:Video
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
protected var _volume:Number = .5
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
public function NetStreamPlayer()
protected function createConnection(command:String = null):void
Parameters
| command:String (default = null )
|
protected function createStream(netstream:NetStream = null):void
Parameters
| netstream:NetStream (default = null )
|
protected function errorHandler(e:ErrorEvent):void
Parameters
protected function getEstimatedLength():int
Returns
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 :
- flv : video/x-flv Flash Video
- f4v : video/mp4 Flash Video
- f4p : video/mp4 Protected Flash Video
- f4b : audio/mp4 Flash Audio Book
- f4a : audio/mp4 Flash Audio
- 3gp : video/3gpp audio/3gpp 3GPP for GSM-based Phones
- 3g2 : video/3gpp audio/3gpp 3GPP2 for CDMA-based Phones
- mov : video/quicktime QuickTime Movie
- mp4 : video/mp4 H.264 MPEG-4 Video
- m4v : video/mp4 H.264 MPEG-4 Video
- m4a : audio/mp4 Audio-only MPEG-4
- p4v : audio/mp4 Protected H.264 MPEG-4 Video
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.
|
public function load(item:*):void
Loads a new file to be played.
Parameters
protected function loadTimerHandler(event:TimerEvent):void
Parameters
protected function netStatusHandler(e:NetStatusEvent):void
Parameters
protected function onCuePoint(o:Object):void
Parameters
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
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
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
protected function playTimerHandler(event:TimerEvent):void
Parameters
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
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
protected function setStatus(str:String):void
Parameters
public function stop():void
Stops the media at the specified position. Sets the position given as the pause position.
protected function trace2(... arguements):void
Parameters
public function unload():void
Stops the media, closes the NetConnetion or NetStream, and resets the metadata.
See also
cv.events.PlayProgressEvent.STATUS
protected function updateProgress():void
protected function updateSoundTransform():void
Event object type: cv.events.MetadataEvent
Dispatched when a cue point is reached.
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.
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.
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 |
cancelable | false ; there is
no default behavior to cancel. |
time | The estimated duration of the media file. |
url | TThe url of the item being loaded. |
currentTarget | The object that is actively processing
the event object with an event listener. |
index | The zero-based index in the DataProvider
that contains the renderer. |
item | A reference to the data that belongs to the renderer. |
mediaType | The type of media being loaded, either "audio" or "video". |
target | The 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. |
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:
Property | Value |
bubbles | false |
cancelable | false ; there is
no default behavior to cancel. |
data | The metadata object. |
currentTarget | The object that is actively processing
the event object with an event listener. |
target | The 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. |
Event object type: cv.events.PlayProgressEvent
Dispatched as a media file finishes playing
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:
Property | Value |
bubbles | false |
cancelable | false ; there is
no default behavior to cancel. |
percent | The percentage of progress for the media playing. |
elapsed | The elapsed time of the media playing. |
remain | The remaining time of the media playing. |
total | The total time of the media playing. |
currentTarget | The object that is actively processing
the event object with an event listener. |
target | The 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. |
Event object type: cv.events.PlayProgressEvent
Dispatched once as a media file first begins to play
Event object type: cv.events.PlayProgressEvent
Dispatched when isPause or isPlaying has updated.
public static const VERSION:String = "3.0.2"
The current version
Copyright 2009 Gabriel Mariani (http://blog.coursevector.com/tempolite)