FLVPlayer

Kind of class:class
Inherits from:Dispatcher
Classpath:org.asapframework.ui.video.FLVPlayer
File last modified:Tuesday, 07 November 2006, 23:09:17
Class for playing FLV files.

Requires a movieclip with an embedded video object with the name "holder_vid".
Currently resizing is not supported; therefore the video object has to have the same size as the video to be played.
Example:
1. In the library, create a new Embedded Video object
2. Create an new MovieClip symbol, and drag the Video object into it.
3. Set the proper size of the Video object, and name it "holder_vid". This name is mandatory!
4. Set the linkage id of the movieclip to "videoContainer". Another name can be used, since this is passed as a parameter to the constructor.

In a controller class, add the following code:
// create the player
mPlayer = new FLVPlayer(mMc, "videoContainer", DEPTH_PLAYER, 0, 0);

// listen to events if necessary; implement the handler functions
// mPlayer.addEventListener(FLVPlayerEvent.PLAY_STARTED, EventDelegate.create(this, onPlayStarted));
// mPlayer.addEventListener(FLVPlayerEvent.STATUS_CHANGE, EventDelegate.create(this, onStatusChange));

// play the video; change the parameters to match your flv path and duration, respectively
mPlayer.playMovie("myMovie.flv", 30);

Alternately, follow steps 1. to 3. above, and then do the following:
4. drag an instance of the created movieclip symbol onto the stage, and name it "video_mc". Another name can be used since the clip is passed as a parameter to the constructor.

On the timeline, add the following code:
// create the player
var player:FLVPlayer = new FLVPlayer(video_mc);
// play the video; change the parameters to match your flv path and duration, respectively
player.playMovie("myMovie.flv", 30);
To do:
A solution needs to be found for issue #1337339 where no PLAY_STARTED event is generated when the buffer size exceeds the length of the video

Constructor

FLVPlayer

function FLVPlayer (
inBaseMC:MovieClip, inLinkageName:String, inDepth:Number, inX:Number, inY:Number)
Constructor
Parameters:
inBaseMC :
movieclip to attach the library symbol to, or the movieclip on the stage that contains the video; video object inside the movieclip must be named "holder_vid".

The following parameters are needed only if a library symbol is attached; otherwise they must be left out.
inLinkageName:
linkage id of a movieclip symbol in the library
inLevel :
depth to attach the library symbol to; ignored if an existing movieclip is passed
inX :
x-position of the new movieclip; ignored if an existing movieclip is passed
inY :
y-position of the new movieclip; ignored if an existing movieclip is passed

Class properties

PAUSED

static PAUSED:String = "paused"
(read,write)

PLAYING

static PLAYING:String = "playing"
(read,write)
Status message received when the first frame has been displayed; video still needs to be preloaded.

STOPPED

static STOPPED:String = "stopped"
(read,write)

Instance properties

flvPath

private flvPath:String
(read,write)

mConnection

private mConnection:NetConnection
(read,write)

mDuration

private mDuration:Number
(read,write)

mHolderMC

private mHolderMC:MovieClip
(read,write)

mMetaData

private mMetaData:FLVMetaData
(read,write)

mStatus

private mStatus:String = STOPPED
(read,write)

mStream

private mStream:NetStream
(read,write)

mVideo

private mVideo:Video
(read,write)

Instance methods

getBytesLoaded

function getBytesLoaded (
) : Number
The loading progress of the movie.

getBytesTotal

function getBytesTotal (
) : Number
The total size of the movie.

getCurrentPlayPercentage

function getCurrentPlayPercentage (
) : Number
Returns the current progress percentage, if the duration has been set. Otherwise returns 0.

getCurrentPlayTime

function getCurrentPlayTime (
) : Number
The current progress time in seconds.

getCurrentProgressFactor

function getCurrentProgressFactor (
) : Number
Returns the current progress factor (0 <= f <= 1); defined only if the duration has been set.

getDuration

function getDuration (
) : Number
The duration of the movie in seconds.

getLoadedPercentage

function getLoadedPercentage (
) : Number
Returns the percentage of the video that has been loaded.

getMetaData

function getMetaData (
FLV meta data as received through NetStream.handleMetaData event.

getStatus

function getStatus (
) : String
The current player status.

handleMetaData

private function handleMetaData (
inData:Object) : Void
Handler for onMetadata event from the NetStream object.
Parameters:
inObj:
the meta data found in this FLV, see NetStream documentation for more info

handleStatusMessage

private function handleStatusMessage (
inObj:Object) : Void
Handler for status messages from the NetStream object.
Parameters:
inObj:
an object containing a String property 'code' with the status details

pause

function pause (
) : Void
Pauses the movie; use resume to resume playing.

play

function play (
) : Void
Starts the movie from the beginning.

playMovie

function playMovie (
inURL:String, inDuration:Number) : Void
Play an FLV movie; specification of duration is necessary only when progress is monitored
Parameters:
inURL :
full path to the FLV movie to be played
inDuration:
duration in seconds

resume

function resume (
) : Void
Resumes the movie after it has been paused.

seek

function seek (
inSeconds:Number) : Void
Seeks to the offset specified (seconds). Pass '0' to rewind the video.

setBufferTime

function setBufferTime (
inTime:Number) : Void
The number of seconds of video to buffer before playing is started;
default is 20 seconds

setDuration

function setDuration (
inD:Number) : Void
The duration of the movie in seconds.

setFilters

function setFilters (
inDeblocking:Number, inSmooth:Boolean) : Void
Set filters for video.
From the documentation of the Video class:
Deblocking indicates the type of deblocking filter applied to decoded video as part of postprocessing. Two deblocking filters are available: one in the Sorenson codec and one in the On2 VP6 codec. The following values are acceptable:
  • 0 (the default)--Let the video compressor apply the deblocking filter as needed.
  • 1--Do not use any deblocking filter.
  • 2--Use the Sorenson deblocking filter.
  • 3--Use the On2 deblocking filter and no deringing filter.
  • 4--Use the On2 deblocking and the fast On2 deringing filter.
  • 5--Use the On2 deblocking and the better On2 deringing filter.
  • 6--Same as 5.
  • 7--Same as 5.

If a mode greater than 2 is selected for video when you are using the Sorenson codec, the Sorenson decoder defaults to mode 2 internally.
Use of a deblocking filter has an effect on overall playback performance, and it is usually not necessary for high-bandwidth video. If your system is not powerful enough, you may experience difficulties playing back video with this filter enabled.
Parameters:
inDeblocking:
type of deblocking
inSmooth :
if true, video is smoothed

setVisible

function setVisible (
inVisible:Boolean) : Void
The visibility of the player (true: visible or false:invisible).

stop

function stop (
) : Void
Stops playing the movie.

toString

function toString (
) : String