Package | flash.media |
Class | public class Video |
Inheritance | Video DisplayObject EventDispatcher Object |
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 Flash Player 9 |
When used with Flash Media Server, the Video object allows you to send live video from a user's computer to the server and then broadcast it from the server to other users. Using these features, you can develop media applications such as a simple video player, a video player with multipoint publishing from one server to another, or a video sharing application for a user community.
Flash Player 9 supports publishing and playback of FLV files encoded with either the Sorenson Spark or On2 VP6 codec and also supports an alpha channel. The On2 VP6 video codec uses less bandwidth than older technologies and offers additional deblocking and deringing filters. See the flash.net.NetStream class for more information about video playback.
Flash Player 9.0.115.0 and later versions support mipmapping to optimize runtime rendering quality and performance.
For video playback, Flash Player uses mipmapping optimization if you set the Video object's smoothing
property to true
.
As with other display objects on the display list,
you can control various properties of Video objects. For example,
you can move the Video object around on the Stage by using its x
and
y
properties, you can change its size using its height
and width
properties, and so on.
To play a video stream, use attachCamera()
or attachNetStream()
to attach the video to the Video object. Then, add the Video object
to the display list using addChild()
.
If you are using the Flash authoring tool, you can also place the Video object on the Stage
rather than adding it with addChild()
, like this:
- If the Library panel isn't visible, select Window > Library to display it.
- Add an embedded Video object to the library by clicking the Options menu on the right side of the Library panel title bar and selecting New Video.
- In the Video Properties dialog box, name the embedded Video object for use in the library and click OK.
- Drag the Video object to the Stage and use the Property Inspector to give it
a unique instance name, such as
my_video
. (Do not name it Video.)
Note:
The Video class is not a subclass of the InteractiveObject class, so
it cannot dispatch mouse events. However, you can call the addEventListener()
method
on the display object container that contains the Video object.
See also
attachNetStream()
flash.media.Camera.getCamera()
flash.net.NetConnection
flash.net.NetStream
flash.display.DisplayObjectContainer.addChild()
flash.display.Stage.addChild()
Property | Defined By | ||
---|---|---|---|
accessibilityProperties : AccessibilityProperties
The current accessibility options for this display object. | DisplayObject | ||
alpha : Number
Indicates the alpha transparency value of the object specified. | DisplayObject | ||
blendMode : String
A value from the BlendMode class that specifies which blend mode to use. | DisplayObject | ||
blendShader : Shader [write-only]
Sets a shader that is used for blending the foreground and background. | DisplayObject | ||
cacheAsBitmap : Boolean
If set to true, Flash Player or Adobe AIR caches an internal bitmap representation of the
display object. | DisplayObject | ||
constructor : Object
A reference to the class object or constructor function for a given object instance. | Object | ||
deblocking : int
Indicates the type of filter applied to decoded video as part of post-processing. | Video | ||
filters : Array
An indexed array that contains each filter object currently associated with the display object. | DisplayObject | ||
height : Number
Indicates the height of the display object, in pixels. | DisplayObject | ||
loaderInfo : LoaderInfo [read-only]
Returns a LoaderInfo object containing information about loading the file
to which this display object belongs. | DisplayObject | ||
mask : DisplayObject
The calling display object is masked by the specified mask object. | DisplayObject | ||
mouseX : Number [read-only]
Indicates the x coordinate of the mouse position, in pixels. | DisplayObject | ||
mouseY : Number [read-only]
Indicates the y coordinate of the mouse position, in pixels. | DisplayObject | ||
name : String
Indicates the instance name of the DisplayObject. | DisplayObject | ||
opaqueBackground : Object
Specifies whether the display object is opaque with a certain background color. | DisplayObject | ||
parent : DisplayObjectContainer [read-only]
Indicates the DisplayObjectContainer object that contains this display object. | DisplayObject | ||
prototype : Object [static]
A reference to the prototype object of a class or function object. | Object | ||
root : DisplayObject [read-only]
For a display object in a loaded SWF file, the root property is the
top-most display object in the portion of the display list's tree structure represented by that SWF file. | DisplayObject | ||
rotation : Number
Indicates the rotation of the DisplayObject instance, in degrees, from its original orientation. | DisplayObject | ||
rotationX : Number
Indicates the x-axis rotation of the DisplayObject instance, in degrees, from its original orientation relative to the 3D parent container. | DisplayObject | ||
rotationY : Number
Indicates the y-axis rotation of the DisplayObject instance, in degrees, from its original orientation relative to the 3D parent container. | DisplayObject | ||
rotationZ : Number
Indicates the z-axis rotation of the DisplayObject instance, in degrees, from its original orientation relative to the 3D parent container. | DisplayObject | ||
scale9Grid : Rectangle
The current scaling grid that is in effect. | DisplayObject | ||
scaleX : Number
Indicates the horizontal scale (percentage) of the object as applied from the registration point. | DisplayObject | ||
scaleY : Number
Indicates the vertical scale (percentage) of an object as applied from the registration point of the object. | DisplayObject | ||
scaleZ : Number
Indicates the depth scale (percentage) of an object as applied from the registration point of the object. | DisplayObject | ||
scrollRect : Rectangle
The scroll rectangle bounds of the display object. | DisplayObject | ||
smoothing : Boolean
Specifies whether the video should be smoothed (interpolated) when it is scaled. | Video | ||
stage : Stage [read-only]
The Stage of the display object. | DisplayObject | ||
transform : flash.geom:Transform
An object with properties pertaining to a display object's matrix, color transform, and pixel bounds. | DisplayObject | ||
videoHeight : int [read-only]
An integer specifying the height of the video stream, in pixels. | Video | ||
videoWidth : int [read-only]
An integer specifying the width of the video stream, in pixels. | Video | ||
visible : Boolean
Whether or not the display object is visible. | DisplayObject | ||
width : Number
Indicates the width of the display object, in pixels. | DisplayObject | ||
x : Number
Indicates the x coordinate of the DisplayObject instance relative to the local coordinates of
the parent DisplayObjectContainer. | DisplayObject | ||
y : Number
Indicates the y coordinate of the DisplayObject instance relative to the local coordinates of
the parent DisplayObjectContainer. | DisplayObject | ||
z : Number
Indicates the z coordinate position along the z-axis of the DisplayObject
instance relative to the 3D parent container. | DisplayObject |
Method | Defined By | ||
---|---|---|---|
Creates a new Video instance. | Video | ||
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener
receives notification of an event. | EventDispatcher | ||
Specifies a video stream from a camera to be displayed
within the boundaries of the Video object in the application. | Video | ||
Specifies a video stream to be displayed within the boundaries of the Video object
in the application. | Video | ||
Clears the image currently displayed in the Video object (not the video stream). | Video | ||
Dispatches an event into the event flow. | EventDispatcher | ||
Returns a rectangle that defines the area of the display object relative to the coordinate system
of the targetCoordinateSpace object. | DisplayObject | ||
Returns a rectangle that defines the boundary of the display object,
based on the coordinate system defined by the targetCoordinateSpace
parameter, excluding any strokes on shapes. | DisplayObject | ||
Converts the point object from the Stage (global) coordinates
to the display object's (local) coordinates. | DisplayObject | ||
Converts a two-dimensional point from the Stage (global) coordinates to a
three-dimensional display object's (local) coordinates. | DisplayObject | ||
Checks whether the EventDispatcher object has any listeners registered for a specific type
of event. | EventDispatcher | ||
Indicates whether an object has a specified property defined. | Object | ||
Evaluates the bounding box of the display object to see if it overlaps or intersects with the
bounding box of the obj display object. | DisplayObject | ||
Evaluates the display object to see if it overlaps or intersects with the
point specified by the x and y parameters. | DisplayObject | ||
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | ||
Converts a three-dimensional point of the three-dimensional display
object's (local) coordinates to a two-dimensional point in the Stage (global) coordinates. | DisplayObject | ||
Converts the point object from the display object's (local) coordinates to the
Stage (global) coordinates. | DisplayObject | ||
Indicates whether the specified property exists and is enumerable. | Object | ||
Removes a listener from the EventDispatcher object. | EventDispatcher | ||
Sets the availability of a dynamic property for loop operations. | Object | ||
Returns the string representation of this object, formatted according to locale-specific conventions. | Object | ||
Returns the string representation of the specified object. | Object | ||
Returns the primitive value of the specified object. | Object | ||
Checks whether an event listener is registered with this EventDispatcher object or any of
its ancestors for the specified event type. | EventDispatcher |
deblocking | property |
deblocking:int
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 Flash Player 9 |
Indicates the type of filter applied to decoded video as part of post-processing. The default value is 0, which lets the video compressor apply a deblocking filter as needed.
Compression of video can result in undesired artifacts. You can use the
deblocking
property to set filters that reduce blocking and,
for video compressed using the On2 codec, ringing.
Blocking refers to visible imperfections between the boundaries of the blocks that compose each video frame. Ringing refers to distorted edges around elements within a video image.
Two deblocking filters are available: one in the Sorenson codec and one in the On2 VP6 codec. In addition, a deringing filter is available when you use the On2 VP6 codec. To set a filter, use one of the following values:
- 0—Lets the video compressor apply the deblocking filter as needed.
- 1—Does not use a deblocking filter.
- 2—Uses the Sorenson deblocking filter.
- 3—For On2 video only, uses the On2 deblocking filter but no deringing filter.
- 4—For On2 video only, uses the On2 deblocking and deringing filter.
- 5—For On2 video only, uses the On2 deblocking and a higher-performance On2 deringing filter.
If a value greater than 2 is selected for video when you are using the Sorenson codec, the Sorenson decoder defaults to 2.
Using a deblocking filter has an effect on overall playback performance, and it is usually not necessary for high-bandwidth video. If a user's system is not powerful enough, the user may experience difficulties playing back video with a deblocking filter enabled.
Implementation
public function get deblocking():int
public function set deblocking(value:int):void
smoothing | property |
smoothing:Boolean
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 Flash Player 9 |
Specifies whether the video should be smoothed (interpolated) when it is scaled. For
smoothing to work, the player must be in high-quality mode. The default value
is false
(no smoothing).
For video playback using Flash Player 9.0.115.0 and later versions, set this property to
true
to take advantage of mipmapping image optimization.
Implementation
public function get smoothing():Boolean
public function set smoothing(value:Boolean):void
videoHeight | property |
videoHeight:int
[read-only] Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 Flash Player 9 |
An integer specifying the height of the video stream, in pixels. For live streams, this
value is the same as the Camera.height
property of the Camera object that is capturing the video stream. For FLV files, this
value is the height of the file that was exported as FLV.
You may want to use this property, for example, to ensure that the user is seeing the video at the same size at which it was captured, regardless of the actual size of the Video object on the Stage.
Implementation
public function get videoHeight():int
See also
videoWidth | property |
videoWidth:int
[read-only] Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 Flash Player 9 |
An integer specifying the width of the video stream, in pixels. For live streams, this
value is the same as the Camera.width
property of the Camera object that is capturing the video stream. For FLV files, this
value is the width of the file that was exported as
an FLV file.
You may want to use this property, for example, to ensure that the user is seeing the video at the same size at which it was captured, regardless of the actual size of the Video object on the Stage.
Implementation
public function get videoWidth():int
See also
Video | () | Constructor |
public function Video(width:int = 320, height:int = 240)
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 Flash Player 9 |
Creates a new Video instance. If no values for the width
and
height
parameters are supplied,
the default values are used. You can also set the width and height properties of the
Video object after the initial construction, using Video.width
and
Video.height
.
When a new Video object is created, values of zero for width or height are not allowed;
if you pass zero, the defaults will be applied.
After creating the Video, call the
DisplayObjectContainer.addChild()
or DisplayObjectContainer.addChildAt()
method to add the Video object to a parent DisplayObjectContainer object.
width:int (default = 320 ) — The width of the video, in pixels.
| |
height:int (default = 240 ) — The height of the video, in pixels.
|
attachCamera | () | method |
public function attachCamera(camera:Camera):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 Flash Player 9 |
Specifies a video stream from a camera to be displayed within the boundaries of the Video object in the application.
Use this method to attach live video from a user's computer to the Video object. You can play the live video locally on the same computer on which it is being captured, or you can send it to Flash Media Server and use the server to stream it to other users.
Parameters
camera:Camera — A Camera object that is capturing video data.
To drop the connection to the Video object, pass null .
|
See also
Example
How to use this example
Please see the Camera.getCamera() method example for an illustration of how to use this method.
attachNetStream | () | method |
public function attachNetStream(netStream:NetStream):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 Flash Player 9 |
Specifies a video stream to be displayed within the boundaries of the Video object
in the application.
The video stream is either an FLV file played
with NetStream.play()
, a Camera object, or null
.
If you use an FLV file, it can be stored on the local file system or on
Flash Media Server.
If the value of the netStream
argument is
null
, the video is no longer played in the Video object.
You do not need to use this method if the FLV file contains only audio; the audio
portion of FLV files is played automatically
when you call NetStream.play()
. To control the audio
associated with an FLV file, use the soundTransform
property
of the NetStream object that plays the FLV file.
Parameters
netStream:NetStream — A NetStream object. To drop the connection to the Video object, pass
null .
|
See also
clear | () | method |
public function clear():void
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 Flash Player 9 |
Clears the image currently displayed in the Video object (not the video stream). This method is useful for handling the current image. For example, you can clear the last image or display standby information without hiding the Video object.
See also
videoURL
,
in this case, an FLV file called Video.flv that is in the same directory as the SWF file.
In this example, the code that creates the Video and NetStream objects and calls
Video.attachNetStream()
and NetStream.play()
is placed
in a handler function. The handler is called only if the
attempt to connect to the NetConnection object is successful, which is
when the netStatus
event returns an info object with a code
property that indicates success.
It is recommended that you wait for a successful connection before calling
NetStream.play()
.
package { import flash.display.Sprite; import flash.events.*; import flash.media.Video; import flash.net.NetConnection; import flash.net.NetStream; public class VideoExample extends Sprite { private var videoURL:String = "Video.flv"; private var connection:NetConnection; private var stream:NetStream; public function VideoExample() { connection = new NetConnection(); connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); connection.connect(null); } private function netStatusHandler(event:NetStatusEvent):void { switch (event.info.code) { case "NetConnection.Connect.Success": connectStream(); break; case "NetStream.Play.StreamNotFound": trace("Unable to locate video: " + videoURL); break; } } private function connectStream():void { stream = new NetStream(connection); stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler); var video:Video = new Video(); video.attachNetStream(stream); stream.play(videoURL); addChild(video); } private function securityErrorHandler(event:SecurityErrorEvent):void { trace("securityErrorHandler: " + event); } private function asyncErrorHandler(event:AsyncErrorEvent):void { // ignore AsyncErrorEvent events. } } }
Fri Mar 19 2010, 02:45 AM -07:00