Packagecom.eyesee360
Classpublic class VideoDisplaySprite
InheritanceVideoDisplaySprite Inheritance flash.display.Sprite

The VideoDisplay control lets you play an FLV file in a Flex application. It supports progressive download over HTTP, streaming from the Flash Media Server, and streaming from a Camera object.

MXML Syntaxexpanded Hide MXML Syntax

The <mx:VideoDisplay> tag inherits all the tag attributes of its superclass, and adds the following tag attributes:

  <mx:VideoDisplay
    Properties
    autoBandWidthDetection="false|true"
    autoPlay="true|false"
    autoRewind="true|false"
    bufferTime="0.1"
    cuePointManagerClass=""
    cuePoints=""
    idleTimeout="300000"
    live="false|true"
    maintainAspectRatio="true|false"
    playheadTime=""
    playheadUpdateInterval="250"
    progressInterval="250"
    source=""
    totalTime=""
    volume="0.75"
  
    Styles
    backgroundAlpha="1.0"
    backgroundColor="0x000000"
    backgroundImage="undefined"
    backgroundSize="undefined"
    borderColor="undefined"
    borderSides="left top right bottom"
    borderSkin="ClassReference('mx.skins.halo.HaloBorder')"
    borderStyle="none"
    borderThickness="1"
    cornerRadius="0"
    dropShadowColor="0x000000"
    dropShadowEnabled="false|true"
    shadowDirection="center"
    shadowDistance="2"
  
    Events
    close="No default"
    complete="No default"
    cuePoint="No default"
    playheadUpdate="No default"
    progress="No default"
    ready="No default"
    rewind="No default"
    stateChange="No default"
   />
  


Public Properties
 PropertyDefined by
  autoBandWidthDetection : Boolean
Specifies whether the VideoDisplay control should use the built-in automatic bandwidth detection feature.
VideoDisplaySprite
  autoPlay : Boolean
Specifies whether the video should start playing immediately when the source property is set.
VideoDisplaySprite
  autoRewind : Boolean
Specifies whether the FLV file should be rewound to the first frame when play stops, either by calling the stop() method or by reaching the end of the stream.
VideoDisplaySprite
  bufferTime : Number
Number of seconds of video to buffer in memory before starting to play the video file.
VideoDisplaySprite
  bytesLoaded : int
[read-only] Number of bytes already loaded that are available for playing.
VideoDisplaySprite
  bytesTotal : int
[read-only] Total number of bytes to load.
VideoDisplaySprite
  cuePointManager : Object
[read-only] The instance of the CuePointManager class associated with the VideoPlayer control.
VideoDisplaySprite
  cuePointManagerClass : Class
Cue point manager to use.
VideoDisplaySprite
  cuePoints : Array
The Array of cue points associated with the control.
VideoDisplaySprite
  idleTimeout : int
Specifies the amount of time, in milliseconds, that the connection is idle (playing is paused or stopped) before the connection to the Flash Media Server is stopped.
VideoDisplaySprite
  live : Boolean
Specifies whether the control is streaming a live feed.
VideoDisplaySprite
  material : VideoPlayerMaterial
[read-only] A PaperVision3D material object that can be used as a surface material for models.
VideoDisplaySprite
  metadata : Object
[read-only] An object that contains a metadata information packet that is received from a call to the NetSteam.onMetaData() callback method, if available.
VideoDisplaySprite
  playheadTime : Number
Playhead position, measured in seconds, since the video starting playing.
VideoDisplaySprite
  playheadUpdateInterval : int
Specifies the amount of time, in milliseconds, between each playheadUpdate event.
VideoDisplaySprite
  playing : Boolean
[read-only] If true, the media is currently playing.
VideoDisplaySprite
  progressInterval : int
Specifies the amount of time, in milliseconds, between each progress event.
VideoDisplaySprite
  source : String
Relative path and filename of the FLV file to stream.
VideoDisplaySprite
  state : String
[read-only] The current state of the VideoDisplay control.
VideoDisplaySprite
  stateResponsive : Boolean
[read-only] Specifies whether the VideoDisplay control is in a responsive state, true, or in the unresponsive state, false.
VideoDisplaySprite
  totalTime : Number
Total length of the media, in seconds.
VideoDisplaySprite
  videoHeight : int
[read-only] Height of the loaded FLV file.
VideoDisplaySprite
  videoWidth : int
[read-only] Width of the loaded FLV file.
VideoDisplaySprite
  volume : Number
The volume level, specified as an value between 0 and 1.
VideoDisplaySprite
Public Methods
 MethodDefined by
  
Constructor.
VideoDisplaySprite
  
attachCamera(camera:Camera):void
Specifies whether to play a video stream from a camera.
VideoDisplaySprite
  
close():void
Forces the close of an input stream and connection to Flash Media Server.
VideoDisplaySprite
  
load():void
Loads the media file without playing it.
VideoDisplaySprite
  
pause():void
Pauses playback without moving the playhead.
VideoDisplaySprite
  
play():void
Plays the media file.
VideoDisplaySprite
  
stop():void
Stops playback.
VideoDisplaySprite
Events
 EventSummaryDefined by
   Dispatched when the NetConnection object is closed, whether by timing out or by calling the close() method.VideoDisplaySprite
   Dispatched when the playhead reaches the end of the FLV file.VideoDisplaySprite
   Dispatched when the value of a cue point's time property is equal to the current playhead location.VideoDisplaySprite
   Dispatched the first time metadata in the FLV file is reached.VideoDisplaySprite
   Dispatched continuosly while the video is playing.VideoDisplaySprite
   Dispatched continuously until the FLV file has downloaded completely.VideoDisplaySprite
   Dispatched when the FLV file is loaded and ready to play.VideoDisplaySprite
   Dispatched when the control autorewinds.VideoDisplaySprite
   Dispatched when the state of the control changes.VideoDisplaySprite
Property detail
autoBandWidthDetectionproperty
autoBandWidthDetection:Boolean  [read-write]

Specifies whether the VideoDisplay control should use the built-in automatic bandwidth detection feature. When false, you do not require a main.asc file on Flash Media Server (FMS) 2 to connect to FMS. When true, you need to implement a main.asc and store it in the directory structure of FMS. The main.asc file must define the following functions:

For more information on writing main.asc, see the FMS documentation.

The default value is false.

This property can be used as the source for data binding.

Implementation
    public function get autoBandWidthDetection():Boolean
    public function set autoBandWidthDetection(value:Boolean):void
autoPlayproperty 
autoPlay:Boolean  [read-write]

Specifies whether the video should start playing immediately when the source property is set. If true, the video file immediately begins to buffer and play.

Even if autoPlay is set to false, Flex starts loading the video after the initialize() method is called. For Flash Media Server, this means creating the stream and loading the first frame to display (and loading more if autoSize or aspectRatio is set to true). In the case of an HTTP download, Flex starts downloading the stream and shows the first frame.

The default value is true.

Implementation
    public function get autoPlay():Boolean
    public function set autoPlay(value:Boolean):void
autoRewindproperty 
autoRewind:Boolean  [read-write]

Specifies whether the FLV file should be rewound to the first frame when play stops, either by calling the stop() method or by reaching the end of the stream. This property has no effect for live streaming video.

The default value is true.

This property can be used as the source for data binding.

Implementation
    public function get autoRewind():Boolean
    public function set autoRewind(value:Boolean):void
bufferTimeproperty 
bufferTime:Number  [read-write]

Number of seconds of video to buffer in memory before starting to play the video file. For slow connections streaming over RTMP, it is important to increase this property from the default.

The default value is 0.1.

This property can be used as the source for data binding.

Implementation
    public function get bufferTime():Number
    public function set bufferTime(value:Number):void
bytesLoadedproperty 
bytesLoaded:int  [read-only]

Number of bytes already loaded that are available for playing. The value is only useful for media loaded using HTTP.

Contains -1 when there is no input stream, when the stream is from Flash Media Server, or if the information is not yet available.

This property can be used as the source for data binding.

Implementation
    public function get bytesLoaded():int
bytesTotalproperty 
bytesTotal:int  [read-only]

Total number of bytes to load. The value is only useful for media loaded using HTTP.

Contains -1 when there is no input stream, when the stream is from Flash Media Server, or if the information is not yet available.

This property can be used as the source for data binding.

Implementation
    public function get bytesTotal():int
cuePointManagerproperty 
cuePointManager:Object  [read-only]

The instance of the CuePointManager class associated with the VideoPlayer control. You can use this object to control cue points, or use the cuePoints property.

You use cue points to trigger cuePoint events when the playback of your video reaches a specified location. To set cue points, you use methods of the CuePointManager class.

Cue points embedded in the FLV are not available via cuePoints or cuePointManager. In order to retrieve them, you can access the metadata property or the metadataReceived event.

Implementation
    public function get cuePointManager():Object

See also

mx.controls.videoClasses.CuePointManager
cuePointManagerClassproperty 
cuePointManagerClass:Class  [read-write]

Cue point manager to use. Set this to mx.controls.videoClasses.CuePointManager to enable cue point management.

Implementation
    public function get cuePointManagerClass():Class
    public function set cuePointManagerClass(value:Class):void

See also

mx.controls.videoClasses.CuePointManager
cuePointsproperty 
cuePoints:Array  [read-write]

The Array of cue points associated with the control. You can use this property to control cue points, or use the cuePointManager property.

You use cue points to trigger cuePoint events when the playback of your video reaches a specified location. To set cue points, you pass an Array to the cuePoints property.

Cue points embedded in the FLV are not available via cuePoints or cuePointManager. In order to retrieve them, you can access the metadata property or the metadataReceived event.

Each element of the Array contains two fields:

This property can be used as the source for data binding.

Implementation
    public function get cuePoints():Array
    public function set cuePoints(value:Array):void
idleTimeoutproperty 
idleTimeout:int  [read-write]

Specifies the amount of time, in milliseconds, that the connection is idle (playing is paused or stopped) before the connection to the Flash Media Server is stopped. This property has no effect on the HTTP download of FLV files. If this property is set when the stream is already idle, it restarts the idle timeout with a new value.

The default value is 300000 (five minutes).

Implementation
    public function get idleTimeout():int
    public function set idleTimeout(value:int):void
liveproperty 
live:Boolean  [read-write]

Specifies whether the control is streaming a live feed. Set this property to true when streaming a live feed from Flash Media Server.

The default value is false.

Implementation
    public function get live():Boolean
    public function set live(value:Boolean):void
materialproperty 
material:VideoPlayerMaterial  [read-only]

A PaperVision3D material object that can be used as a surface material for models.

This property can be used as the source for data binding.

Implementation
    public function get material():VideoPlayerMaterial
metadataproperty 
metadata:Object  [read-only]

An object that contains a metadata information packet that is received from a call to the NetSteam.onMetaData() callback method, if available. Ready when the metadataReceived event is dispatched.

If the FLV file is encoded with the Flash 8 encoder, the metadata property contains the following information. Older FLV files contain only the height, width, and duration values.

ParameterDescription
canSeekToEndA Boolean value that is true if the FLV file is encoded with a keyframe on the last frame that allows seeking to the end of a progressive download movie clip. It is false if the FLV file is not encoded with a keyframe on the last frame.
cuePointsAn Array of objects, one for each cue point embedded in the FLV file. Value is undefined if the FLV file does not contain any cue points. Each object has the following properties:
  • type—A String that specifies the type of cue point as either "navigation" or "event".
  • name—A String that is the name of the cue point.
  • time—A Number that is the time of the cue point in seconds with a precision of three decimal places (milliseconds).
  • parameters—An optional Object that has name-value pairs that are designated by the user when creating the cue points.
audiocodecidA Number that indicates the audio codec (code/decode technique) that was used.
audiodelay A Number that represents time 0 in the source file from which the FLV file was encoded.

Video content is delayed for the short period of time that is required to synchronize the audio. For example, if the audiodelay value is .038, the video that started at time 0 in the source file starts at time .038 in the FLV file.

Note that the VideoDisplay class compensates for this delay in its time settings. This means that you can continue to use the time settings that you used in your the source file.

audiodatarateA Number that is the kilobytes per second of audio.
videocodecidA Number that is the codec version that was used to encode the video.
framerateA Number that is the frame rate of the FLV file.
videodatarateA Number that is the video data rate of the FLV file.
heightA Number that is the height of the FLV file.
widthA Number that is the width of the FLV file.
durationA Number that specifies the duration of the FLV file in seconds.

This property can be used as the source for data binding.

Implementation
    public function get metadata():Object
playheadTimeproperty 
playheadTime:Number  [read-write]

Playhead position, measured in seconds, since the video starting playing. The event object for many of the VideoPlay events include the playhead position so that you can determine the location in the video file where the event occurred.

Setting this property to a value in seconds performs a seek operation. If the video is currently playing, it continues playing from the new playhead position. If the video is paused, it seeks to the new playhead position and remains paused. If the video is stopped, it seeks to the new playhead position and enters the paused state. Setting this property has no effect with live video streams.

If the new playhead position is less than 0 or NaN, the control throws an exception. If the new playhead position is past the end of the video, or past the amount of the video file downloaded so far, then the control still attempts the seek.

For an FLV file, setting the playheadTime property seeks to the keyframe closest to the specified position, where keyframes are specified in the FLV file at the time of encoding. Therefore, you might not seek to the exact time if there is no keyframe specified at that position.

If player is in an unresponsive state, it queues the request.

This property throws an exception if set when no stream is connected. Use the stateChange event and the connected property to determine when it is safe to set this property.

The default value is NaN.

This property can be used as the source for data binding.

Implementation
    public function get playheadTime():Number
    public function set playheadTime(value:Number):void
playheadUpdateIntervalproperty 
playheadUpdateInterval:int  [read-write]

Specifies the amount of time, in milliseconds, between each playheadUpdate event.

If you set this property when the video is playing, the timer restarts at 0, and the next playheadUpdate event occurs after the new time interval.

The default value is 250.

Implementation
    public function get playheadUpdateInterval():int
    public function set playheadUpdateInterval(value:int):void
playingproperty 
playing:Boolean  [read-only]

If true, the media is currently playing.

This property can be used as the source for data binding.

Implementation
    public function get playing():Boolean
progressIntervalproperty 
progressInterval:int  [read-write]

Specifies the amount of time, in milliseconds, between each progress event. The progress event occurs continuously until the video file downloads completely.

If you set this property when the video is downloading, the timer restarts at 0, and the next progress event occurs after the new time interval.

The default value is 250.

Implementation
    public function get progressInterval():int
    public function set progressInterval(value:int):void
sourceproperty 
source:String  [read-write]

Relative path and filename of the FLV file to stream.

This property can be used as the source for data binding.

Implementation
    public function get source():String
    public function set source(value:String):void
stateproperty 
state:String  [read-only]

The current state of the VideoDisplay control. You set this property by calls to the load(), play(), stop(), and pause() methods, and setting the playHeadTime property.

This property can have the following values defined in the VideoEvent class: VideoEvent.BUFFERING, VideoEvent.CONNECTION_ERROR, VideoEvent.DISCONNECTED, VideoEvent.EXEC_QUEUED_CMD, VideoEvent.LOADING, VideoEvent.PAUSED, VideoEvent.PLAYING, VideoEvent.RESIZING, VideoEvent.REWINDING, VideoEvent.SEEKING, and VideoEvent.STOPPED.

The default value is VideoEvent.DISCONNECTED.

This property can be used as the source for data binding.

Implementation
    public function get state():String

See also

mx.events.VideoEvent
stateResponsiveproperty 
stateResponsive:Boolean  [read-only]

Specifies whether the VideoDisplay control is in a responsive state, true, or in the unresponsive state, false. The control enters the unresponsive state when video is being loaded or is rewinding.

The control is also in a responsive state when the state property is: VideoEvent.CONNECTION_ERROR, VideoEvent.EXEC_QUEUED_CMD, VideoEvent.RESIZING, or VideoEvent.SEEKING.

If the control is unresponsive, calls to the play(), load(), stop(), and pause() methods are queued, and then executed when the control changes to the responsive state.

This property can be used as the source for data binding.

Implementation
    public function get stateResponsive():Boolean
totalTimeproperty 
totalTime:Number  [read-write]

Total length of the media, in seconds. For FLV 1.0 video files, you manually set this property. For FLV 1.1 and later, the control calculates this value automatically.

This property can be used as the source for data binding.

Implementation
    public function get totalTime():Number
    public function set totalTime(value:Number):void
videoHeightproperty 
videoHeight:int  [read-only]

Height of the loaded FLV file. -1 if no FLV file loaded yet.

This property can be used as the source for data binding.

Implementation
    public function get videoHeight():int
videoWidthproperty 
videoWidth:int  [read-only]

Width of the loaded FLV file. -1 if no FLV file loaded yet.

This property can be used as the source for data binding.

Implementation
    public function get videoWidth():int
volumeproperty 
volume:Number  [read-write]

The volume level, specified as an value between 0 and 1.

The default value is 0.75.

This property can be used as the source for data binding.

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

Constructor.

Method detail
attachCamera()method
public function attachCamera(camera:Camera):void

Specifies whether to play a video stream from a camera. The video is displayed within the boundaries of the control in the application window.

Parameters
camera:Camera — A Camera object that is capturing video data.
close()method 
public function close():void

Forces the close of an input stream and connection to Flash Media Server. Calling this method dispatches the close event. Typically calling this method directly is not necessary because the connection is automatically closed when the idle period times out, as defined by the idleTimeout property.

load()method 
public function load():void

Loads the media file without playing it.

This method is similar to the play() method, but it causes the file to be loaded without playing. Autoresizing will occur if appropriate. After the load and autoresize, the state of the control is set to VideoEvent.PAUSED.

pause()method 
public function pause():void

Pauses playback without moving the playhead. If playback is already is paused or is stopped, this method has no effect.

To start playback again, call the play() method.

If the control is in an unresponsive state, the request is queued.

play()method 
public function play():void

Plays the media file. If the file has not been loaded, it loads it. You can call this method while playback is paused, stopped, or while the control is playing.

If the control is in an unresponsive state, the request is queued.

stop()method 
public function stop():void

Stops playback. If the autoRewind property is set to true, rewind to the first frame.

To start playback again, call the play() method.

If playback is already stopped, this method has no effect. If the control is in an unresponsive state, the request is queued.

Event detail
closeevent 
Event object type: mx.events.VideoEvent

Dispatched when the NetConnection object is closed, whether by timing out or by calling the close() method. You use this event when working with Flash Media Server.

completeevent  
Event object type: mx.events.VideoEvent

Dispatched when the playhead reaches the end of the FLV file.

cuePointevent  
Event object type: mx.events.CuePointEvent

Dispatched when the value of a cue point's time property is equal to the current playhead location.

metadataReceivedevent  
Event object type: mx.events.MetadataEvent

Dispatched the first time metadata in the FLV file is reached.

playheadUpdateevent  
Event object type: mx.events.VideoEvent

Dispatched continuosly while the video is playing. The interval between events, in milliseconds, is specified by the playheadUpdateInterval property, which defaults to 250 ms. This event is not dispatched when the video is in a paused or stopped state.

progressevent  
Event object type: flash.events.ProgressEvent

Dispatched continuously until the FLV file has downloaded completely.

You can use this event to check the number of bytes loaded or the number of bytes in the buffer. This event starts getting dispatched when the load() or play() method is called first and ends when all bytes are loaded or if there is a network error.

readyevent  
Event object type: mx.events.VideoEvent

Dispatched when the FLV file is loaded and ready to play.

This event is dispatched the first time the VideoDisplay control enters a responsive state after a new FLV file is loaded by the load() or play() method. It is dispatched only once for each FLV file loaded.

rewindevent  
Event object type: mx.events.VideoEvent

Dispatched when the control autorewinds.

See also

stateChangeevent  
Event object type: mx.events.VideoEvent

Dispatched when the state of the control changes.

You can use this event to track when playback enters and leaves the unresponsive state (for example, in the middle of connecting, resizing, or rewinding), during which time calls to the play(), pause(), and stop() methods and writes to the playHeadTime property are queued, and then executed when the player enters the responsive state.