| Package | com.greensock.loading |
| Class | public class VideoLoader |
| Inheritance | VideoLoader LoaderItem LoaderCore flash.events.EventDispatcher |
pauseVideo(), playVideo(), gotoVideoTime(), bufferProgress, playProgress, volume,
duration, videoPaused, metaData, and videoTime. Just like ImageLoader and SWFLoader,
VideoLoader's content property refers to a ContentDisplay object (Sprite) that
gets created immediately so that you can position/scale/rotate it or add ROLL_OVER/ROLL_OUT/CLICK listeners
before (or while) the video loads. Use the VideoLoader's content property to get the ContentDisplay
Sprite, or use the rawContent property to get the Video object that is used inside the
ContentDisplay to display the video. If a container is defined in the vars object,
the ContentDisplay will immediately be added to that container).
You don't need to worry about creating a NetConnection, a Video object, attaching the NetStream, or any
of the typical hassles. VideoLoader can even scale the video into the area you specify using scaleModes
like "stretch", "proportionalInside", "proportionalOutside", and more. A VideoLoader will
dispatch useful events like VIDEO_COMPLETE, VIDEO_PAUSE, VIDEO_PLAY, VIDEO_BUFFER_FULL,
VIDEO_BUFFER_EMPTY, NET_STATUS, VIDEO_CUE_POINT, and PLAY_PROGRESS in addition
to the typical loader events, making it easy to hook up your own control interface. It packs a
surprising amount of functionality into a very small amount of kb.
OPTIONAL VARS PROPERTIES
The following special properties can be passed into the VideoLoader constructor via its vars
parameter which can be either a generic object or a
VideoLoaderVars
object:
LoaderMax.getLoader() or LoaderMax.getContent() methods or traced at any time. Each loader's name should be unique. If you don't define one, a unique name will be created automatically, like "loader21".autoPlay to false to pause the video initially).autoPlay to false.smoothing is true (the default), smoothing will be enabled for the video which typically leads to better scaling results.ContentDisplay should be added immediately.ContentDisplay's width property (applied before rotation, scaleX, and scaleY).ContentDisplay's height property (applied before rotation, scaleX, and scaleY).true, the registration point will be placed in the center of the ContentDisplay which can be useful if, for example, you want to animate its scale and have it grow/shrink from its center.width and height are defined, the scaleMode controls how the video will be scaled to fit the area. The following values are recognized (you may use the com.greensock.layout.ScaleMode constants if you prefer):
"stretch" (the default) - The video will fill the width/height exactly."proportionalInside" - The video will be scaled proportionally to fit inside the area defined by the width/height"proportionalOutside" - The video will be scaled proportionally to completely fill the area, allowing portions of it to exceed the bounds defined by the width/height."widthOnly" - Only the width of the video will be adjusted to fit."heightOnly" - Only the height of the video will be adjusted to fit."none" - No scaling of the video will occur.width and height are defined, the hAlign determines how the video is horizontally aligned within that area. The following values are recognized (you may use the com.greensock.layout.AlignMode constants if you prefer):
"center" (the default) - The video will be centered horizontally in the area"left" - The video will be aligned with the left side of the area"right" - The video will be aligned with the right side of the areawidth and height are defined, the vAlign determines how the video is vertically aligned within that area. The following values are recognized (you may use the com.greensock.layout.AlignMode constants if you prefer):
"center" (the default) - The video will be centered vertically in the area"top" - The video will be aligned with the top of the area"bottom" - The video will be aligned with the bottom of the areawidth and height are defined, setting crop to true will cause the video to be cropped within that area (by applying a scrollRect for maximum performance). This is typically useful when the scaleMode is "proportionalOutside" or "none" so that any parts of the video that exceed the dimensions defined by width and height are visually chopped off. Use the hAlign and vAlign special properties to control the vertical and horizontal alignment within the cropped area.ContentDisplay's x property (for positioning on the stage).ContentDisplay's y property (for positioning on the stage).ContentDisplay's scaleX property.ContentDisplay's scaleY property.ContentDisplay's rotation property.ContentDisplay's alpha property.ContentDisplay's visible property.ContentDisplay's blendMode property.width and height are defined, a rectangle will be drawn inside the ContentDisplay immediately in order to ease the development process. It is transparent by default, but you may define a bgAlpha if you prefer.width and height are defined.Video object, but if you want to use StageVideo in Flash, you can define the stageVideo property and VideoLoader will attach its NetStream to that StageVideo instance instead of the regular Video instance (which is the rawContent). Please read Adobe's docs regarding StageVideo to understand the benefits, tradeoffs and limitations.true, the VideoLoader will check for a crossdomain.xml file on the remote host (only useful when loading videos from other domains - see Adobe's docs for details about NetStream's checkPolicyFile property). estimatedDuration, but doing so can help make the playProgress and some other values more accurate (until the metaData has loaded). It can also make the progress/bytesLoaded/bytesTotal more accurate when a estimatedDuration is defined, particularly in bufferMode.flash.media.Video class docs for details.true, the loader will report its progress only in terms of the video's buffer which can be very convenient if, for example, you want to display loading progress for the video's buffer or tuck it into a LoaderMax with other loaders and allow the LoaderMax to dispatch its COMPLETE event when the buffer is full instead of waiting for the whole file to download. When bufferMode is true, the VideoLoader will dispatch its COMPLETE event when the buffer is full as opposed to waiting for the entire video to load. You can toggle the bufferMode anytime. Please read the full bufferMode property ASDoc description below for details about how it affects things like bytesTotal.autoAdjustBuffer is true (the default), it will automatically attempt to adjust the NetStream's bufferTime based on the rate at which the video has been loading, estimating what it needs to be in order to play the rest of the video without emptying the buffer again. This can prevent the annoying problem of video playback start/stopping/starting/stopping on a system tht doesn't have enough bandwidth to adequately buffer the video. You may also set the bufferTime in the constructor's vars parameter to set the initial value.true, the NetStream will only be attached to the Video object (the rawContent) when it is in the display list (on the stage). This conserves memory but it can cause a very brief rendering delay when the content is initially added to the stage (often imperceptible). Also, if you add it to the stage when the videoTime is after its last encoded keyframe, it will render at that last keyframe.alternateURL, the loader will initially try to load from its original url and if it fails, it will automatically (and permanently) change the loader's url to the alternateURL and try again. Think of it as a fallback or backup url. It is perfectly acceptable to use the same alternateURL for multiple loaders (maybe a default image for various ImageLoaders for example).noCache is true, a "gsCacheBusterID" parameter will be appended to the url with a random set of numbers to prevent caching (don't worry, this info is ignored when you getLoader() or getContent() by url and when you're running locally)bytesTotal is set to the estimatedBytes value (or LoaderMax.defaultEstimatedBytes if one isn't defined). Then, when the loader begins loading and it can accurately determine the bytesTotal, it will do so. Setting estimatedBytes is optional, but the more accurate the value, the more accurate your loaders' overall progress will be initially. If the loader will be inserted into a LoaderMax instance (for queue management), its auditSize feature can attempt to automatically determine the bytesTotal at runtime (there is a slight performance penalty for this, however - see LoaderMax's documentation for details).requireWithRoot property to your swf's root. For example, var loader:VideoLoader = new VideoLoader("myScript.php", {name:"textData", requireWithRoot:this.root});
allowMalformedURL:true. For example, if your URL has duplicate variables in the query string like http://www.greensock.com/?c=S&c=SE&c=SW, it is technically considered a malformed URL and a URLVariables object can't properly contain all the duplicates, so in this case you'd want to set allowMalformedURL to true.autoDispose is true, the loader will be disposed immediately after it completes (it calls the dispose() method internally after dispatching its COMPLETE event). This will remove any listeners that were defined in the vars object (like onComplete, onProgress, onError, onInit). Once a loader is disposed, it can no longer be found with LoaderMax.getLoader() or LoaderMax.getContent() - it is essentially destroyed but its content is not unloaded (you must call unload() or dispose(true) to unload its content). The default autoDispose value is false.
----EVENT HANDLER SHORTCUTS----
LoaderEvent.OPEN events which are dispatched when the loader begins loading. Make sure your onOpen function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).Event.INIT events which will be called when the video's metaData has been received and the video is placed into the ContentDisplay. The INIT event can be dispatched more than once if the NetStream receives metaData more than once (which occasionally happens, particularly with F4V files - the first time often doesn't include the cuePoints). Make sure your onInit function accepts a single parameter of type Event (flash.events.Event).LoaderEvent.PROGRESS events which are dispatched whenever the bytesLoaded changes. Make sure your onProgress function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent). You can use the LoaderEvent's target.progress to get the loader's progress value or use its target.bytesLoaded and target.bytesTotal.LoaderEvent.COMPLETE events which are dispatched when the loader has finished loading successfully. Make sure your onComplete function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).LoaderEvent.CANCEL events which are dispatched when loading is aborted due to either a failure or because another loader was prioritized or cancel() was manually called. Make sure your onCancel function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).LoaderEvent.ERROR events which are dispatched whenever the loader experiences an error (typically an IO_ERROR). An error doesn't necessarily mean the loader failed, however - to listen for when a loader fails, use the onFail special property. Make sure your onError function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).LoaderEvent.FAIL events which are dispatched whenever the loader fails and its status changes to LoaderStatus.FAILED. Make sure your onFail function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).LoaderEvent.IO_ERROR events which will also call the onError handler, so you can use that as more of a catch-all whereas onIOError is specifically for LoaderEvent.IO_ERROR events. Make sure your onIOError function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
Note: Using a
VideoLoaderVars
instance
instead of a generic object to define your vars is a bit more verbose but provides
code hinting and improved debugging because it enforces strict data typing. Use whichever one you prefer.
Note: To avoid garbage collection issues in the Flash player, the netStream
object that VideoLoader employs must get recreated internally anytime the VideoLoader is unloaded or its loading
is cancelled, so if you need to directly access the netStream, it is best to do so after
the COMPLETE event has been dispatched. Otherwise, if you store a reference to the VideoLoader's
netStream before or during a load and it gets cancelled or unloaded for some reason, it won't reference
the one that was used to load the video.
Note: There is a bug/inconsistency in Adobe's NetStream class that causes relative URLs to use the swf's location as the base path instead of the HTML page's location like all other loaders. Therefore, it would be wise to use the "base" attribute of the <OBJECT> and <EMBED> tags in the HTML to make sure all relative paths are consistent. See http://kb2.adobe.com/cps/041/tn_04157.html for details.
Note: In order to minimize memory usage, VideoLoader doesn't attach the NetStream to its Video
object (the rawContent) until it is added to the display list. Therefore, if your VideoLoader's content
isn't somewhere on the stage, the NetStream's visual content won't be fully decoded into memory (that's a good thing).
The only time this could be of consequence is if you are trying to do a BitmapData.draw() of the VideoLoader's content
or rawContent when it isn't on the stage. In that case, you'd just need to attach the NetStream manually before doing
your BitmapData.draw() like myVideoLoader.rawContent.attachNetStream(myVideoLoader.netStream).
import com.greensock.loading.*;
import com.greensock.loading.display.*;
import com.greensock.*;
import com.greensock.events.LoaderEvent;
//create a VideoLoader
var video:VideoLoader = new VideoLoader("assets/video.flv", {name:"myVideo", container:this, width:400, height:300, scaleMode:"proportionalInside", bgColor:0x000000, autoPlay:false, volume:0, requireWithRoot:this.root, estimatedBytes:75000});
//start loading
video.load();
//add a CLICK listener to a button that causes the video to toggle its paused state.
button.addEventListener(MouseEvent.CLICK, togglePause);
function togglePause(event:MouseEvent):void {
video.videoPaused = !video.videoPaused;
}
//or you could put the VideoLoader into a LoaderMax queue. Create one first...
var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler});
//append the VideoLoader and several other loaders
queue.append( video );
queue.append( new DataLoader("assets/data.txt", {name:"myText"}) );
queue.append( new ImageLoader("assets/image1.png", {name:"myImage", estimatedBytes:3500}) );
//start loading the LoaderMax queue
queue.load();
function progressHandler(event:LoaderEvent):void {
trace("progress: " + event.target.progress);
}
function completeHandler(event:LoaderEvent):void {
//play the video
video.playVideo();
//tween the volume up to 1 over the course of 2 seconds.
TweenLite.to(video, 2, {volume:1});
}
function errorHandler(event:LoaderEvent):void {
trace("error occured with " + event.target + ": " + event.text);
}
Copyright 2010-2013, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for Club GreenSock members, the software agreement that was issued with the membership.
See also
| Property | Defined By | ||
|---|---|---|---|
![]() | auditedSize : Boolean [read-only]
Indicates whether or not the loader's bytesTotal value has been set by any of the following:
Defining an estimatedBytes in the vars object passed to the constructor
Calling auditSize() and getting a response (an error is also considered a response)
When a LoaderMax instance begins loading, it will automatically force a call to auditSize() for any of its children that don't have an estimatedBytes defined. | LoaderCore | |
| autoAdjustBuffer : Boolean If the buffer becomes empty during playback and autoAdjustBuffer is true (the default), it will automatically attempt to adjust the NetStream's bufferTime based on the rate at which the video has been loading, estimating what it needs to be in order to play the rest of the video without emptying the buffer again. | VideoLoader | ||
| autoDetachNetStream : Boolean If true (the default), the NetStream will only be attached to the Video object (the rawContent) when it is in the display list (on the stage). | VideoLoader | ||
![]() | autoDispose : Boolean When autoDispose is true, the loader will be disposed immediately after it completes (it calls the dispose() method internally after dispatching its COMPLETE event). | LoaderCore | |
| bufferMode : Boolean
When bufferMode is true, the loader will report its progress only in terms of the
video's buffer instead of its overall file loading progress which has the following effects:
The bytesTotal will be calculated based on the NetStream's duration, bufferLength, and bufferTime meaning it may fluctuate in order to accurately reflect the overall progress ratio.
Its COMPLETE event will be dispatched as soon as the buffer is full, so if the VideoLoader is nested in a LoaderMax, the LoaderMax will move on to the next loader in its queue at that point. | VideoLoader | ||
| bufferProgress : Number [read-only] A value between 0 and 1 describing the progress of the buffer (0 = not buffered at all, 0.5 = halfway buffered, and 1 = fully buffered). | VideoLoader | ||
![]() | bytesLoaded : uint [read-only] Bytes loaded | LoaderCore | |
![]() | bytesTotal : uint [read-only] Total bytes that are to be loaded by the loader. | LoaderCore | |
| content : * [override] [read-only] A ContentDisplay (a Sprite) that contains a Video object to which the NetStream is attached. | VideoLoader | ||
| duration : Number [read-only] The duration (in seconds) of the video. | VideoLoader | ||
![]() | httpStatus : int [read-only] The httpStatus code of the loader. | LoaderItem | |
![]() | loadTime : Number [read-only]
The number of seconds that elapsed between when the loader began and when it either completed, failed,
or was canceled. | LoaderCore | |
| metaData : Object The metaData that was received from the video (contains information about its width, height, frame rate, etc.). | VideoLoader | ||
![]() | name : String A name that you use to identify the loader instance. | LoaderCore | |
| netStream : NetStream [read-only] The NetStream object used to load the video | VideoLoader | ||
![]() | paused : Boolean If a loader is paused, its progress will halt and any LoaderMax instances to which it belongs will either skip over it or stop when its position is reached in the queue (depending on whether or not the LoaderMax's skipPaused property is true). | LoaderCore | |
| playProgress : Number A value between 0 and 1 describing the playback progress where 0 means the virtual playhead is at the very beginning of the video, 0.5 means it is at the halfway point and 1 means it is at the end of the video. | VideoLoader | ||
![]() | progress : Number [read-only] A value between 0 and 1 indicating the overall progress of the loader. | LoaderCore | |
| rawContent : Video [read-only] The Video object to which the NetStream was attached (automatically created by VideoLoader internally) | VideoLoader | ||
![]() | request : URLRequest [read-only] The URLRequest associated with the loader. | LoaderItem | |
![]() | scriptAccessDenied : Boolean [read-only]
If the loaded content is denied script access (because of security sandbox restrictions,
a missing crossdomain.xml file, etc.), scriptAccessDenied will be set to true. | LoaderItem | |
| soundTransform : SoundTransform The soundTransform of the NetStream associated with the VideoLoader (this gets refreshed when the VideoLoader is unloaded or reloaded). | VideoLoader | ||
| stageVideo : Object By default, the NetStream gets attached to a Video object, but if you want to use StageVideo in Flash, you can define the stageVideo object and VideoLoader will attach its NetStream to that StageVideo instance instead of the regular Video instance (which is the rawContent). | VideoLoader | ||
![]() | status : int [read-only] Integer code indicating the loader's status; options are LoaderStatus.READY, LoaderStatus.LOADING, LoaderStatus.COMPLETED, LoaderStatus.PAUSED, and LoaderStatus.DISPOSED. | LoaderCore | |
![]() | url : String The url from which the loader should get its content. | LoaderItem | |
![]() | vars : Object An object containing optional configuration details, typically passed through a constructor parameter. | LoaderCore | |
| videoPaused : Boolean The playback status of the video: true if the video's playback is paused, false if it isn't. | VideoLoader | ||
| videoTime : Number The time (in seconds) at which the virtual playhead is positioned on the video. | VideoLoader | ||
| volume : Number The volume of the video (a value between 0 and 1). | VideoLoader | ||
| Method | Defined By | ||
|---|---|---|---|
VideoLoader(urlOrRequest:*, vars:Object = null)
Constructor
| VideoLoader | ||
addASCuePoint(time:Number, name:String, parameters:Object = null):Object
Adds an ActionScript cue point. | VideoLoader | ||
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void [override] | VideoLoader | ||
auditSize():void [override]
Attempts loading just enough of the content to accurately determine the bytesTotal
in order to improve the accuracy of the progress property. | VideoLoader | ||
![]() | cancel():void
If the loader is currently loading (status is LoaderStatus.LOADING), it will be canceled
immediately and its status will change to LoaderStatus.READY. | LoaderCore | |
clearVideo():void Clears the video from the rawContent (the Video object). | VideoLoader | ||
![]() | dispose(flushContent:Boolean = false):void
Disposes of the loader and releases it internally for garbage collection. | LoaderCore | |
getCuePointTime(name:String):Number
Finds a cue point by name and returns its corresponding time (where it is positioned in the video). | VideoLoader | ||
gotoVideoCuePoint(name:String, forcePlay:Boolean = false, skipCuePoints:Boolean = true):Number
Attempts to jump to a certain cue point (either a cue point that was embedded in the
video itself when it was encoded or a cue point that was added via addASCuePoint()). | VideoLoader | ||
gotoVideoTime(time:Number, forcePlay:Boolean = false, skipCuePoints:Boolean = true):Number
Attempts to jump to a certain time in the video. | VideoLoader | ||
![]() | load(flushContent:Boolean = false):void
Loads the loader's content, optionally flushing any previously loaded content first. | LoaderCore | |
![]() | pause():void Pauses the loader immediately. | LoaderCore | |
pauseVideo(event:Event = null):void
Pauses playback of the video. | VideoLoader | ||
playVideo(event:Event = null):void
Plays the video (if the buffer isn't full yet, playback will wait until the buffer is full). | VideoLoader | ||
![]() | prioritize(loadNow:Boolean = true):void
Immediately prioritizes the loader inside any LoaderMax instances that contain it,
forcing it to the top position in their queue and optionally calls load()
immediately as well. | LoaderCore | |
removeASCuePoint(timeNameOrCuePoint:*):Object
Removes an ActionScript cue point that was added with addASCuePoint(). | VideoLoader | ||
repeatCount(value:int = 0):*
Sets or gets the current repeat count (how many times the video has repeated, as determined
by the "repeat" special property that was passed into the constructor). | VideoLoader | ||
![]() | resume():void Unpauses the loader and resumes loading immediately. | LoaderCore | |
![]() | toString():String [override] Returns information about the loader, like its type, its name, and its url (if it has one). | LoaderCore | |
![]() | unload():void
Removes any content that was loaded and sets bytesLoaded back to zero. | LoaderCore | |
| Method | Defined By | ||
|---|---|---|---|
_seek(time:Number):void | VideoLoader | ||
| Event | Summary | Defined By | ||
|---|---|---|---|---|
![]() | Dispatched when the loader is canceled while loading which can occur either because of a failure or when a sibling loader is prioritized in a LoaderMax queue. | LoaderCore | ||
![]() | Dispatched when the loader completes. | LoaderCore | ||
![]() | Dispatched when the loader experiences some type of error, like a SECURITY_ERROR or IO_ERROR. | LoaderCore | ||
![]() | Dispatched when the loader fails. | LoaderCore | ||
| Dispatched when the loader's httpStatus value changes. | VideoLoader | |||
![]() | Dispatched when the loader experiences an IO_ERROR while loading or auditing its size. | LoaderItem | ||
| Dispatched when the netStream dispatches a NET_STATUS event. | VideoLoader | |||
![]() | Dispatched when the loader starts loading. | LoaderCore | ||
![]() | Dispatched each time the bytesLoaded value changes while loading (indicating progress). | LoaderCore | ||
![]() | Dispatched when the loader unloads (which happens when either unload() or dispose(true) is called or if a loader is canceled while in the process of loading). | LoaderCore | ||
| Constant | Defined By | ||
|---|---|---|---|
| PLAY_PROGRESS : String = playProgress [static] Event type constant for when the playback progresses (only dispatched when the video is playing). | VideoLoader | ||
| VIDEO_BUFFER_EMPTY : String = videoBufferEmpty [static] Event type constant for when the video's buffer is empty. | VideoLoader | ||
| VIDEO_BUFFER_FULL : String = videoBufferFull [static] Event type constant for when the video's buffer is full. | VideoLoader | ||
| VIDEO_COMPLETE : String = videoComplete [static] Event type constant for when the video completes. | VideoLoader | ||
| VIDEO_CUE_POINT : String = videoCuePoint [static] Event type constant for when the video reaches a cue point in the playback of the NetStream. | VideoLoader | ||
| VIDEO_PAUSE : String = videoPause [static] Event type constant for when the video is paused. | VideoLoader | ||
| VIDEO_PLAY : String = videoPlay [static] Event type constant for when the video begins or resumes playing. | VideoLoader | ||
| autoAdjustBuffer | property |
public var autoAdjustBuffer:Boolean If the buffer becomes empty during playback and autoAdjustBuffer is true (the default), it will automatically attempt to adjust the NetStream's bufferTime based on the rate at which the video has been loading, estimating what it needs to be in order to play the rest of the video without emptying the buffer again. This can prevent the annoying problem of video playback start/stopping/starting/stopping on a system tht doesn't have enough bandwidth to adequately buffer the video. You may also set the bufferTime in the constructor's vars parameter to set the initial value.
| autoDetachNetStream | property |
autoDetachNetStream:Boolean If true (the default), the NetStream will only be attached to the Video object (the rawContent) when it is in the display list (on the stage). This conserves memory but it can cause a very brief rendering delay when the content is initially added to the stage (often imperceptible). Also, if you add it to the stage when the videoTime is after its last encoded keyframe, it will render at that last keyframe.
public function get autoDetachNetStream():Boolean public function set autoDetachNetStream(value:Boolean):void| bufferMode | property |
bufferMode:Boolean
When bufferMode is true, the loader will report its progress only in terms of the
video's buffer instead of its overall file loading progress which has the following effects:
bytesTotal will be calculated based on the NetStream's duration, bufferLength, and bufferTime meaning it may fluctuate in order to accurately reflect the overall progress ratio.COMPLETE event will be dispatched as soon as the buffer is full, so if the VideoLoader is nested in a LoaderMax, the LoaderMax will move on to the next loader in its queue at that point. However, the VideoLoader's NetStream will continue to load in the background, using up bandwidth.This can be very convenient if, for example, you want to display loading progress based on the video's buffer
or if you want to load a series of loaders in a LoaderMax and have it fire its COMPLETE event
when the buffer is full (as opposed to waiting for the entire video to load).
public function get bufferMode():Boolean public function set bufferMode(value:Boolean):void| bufferProgress | property |
bufferProgress:Number [read-only] A value between 0 and 1 describing the progress of the buffer (0 = not buffered at all, 0.5 = halfway buffered, and 1 = fully buffered). The buffer progress is in relation to the bufferTime which is 5 seconds by default or you can pass a custom value in through the vars parameter in the constructor like {bufferTime:20}.
public function get bufferProgress():Number| content | property |
content:* [read-only] [override] A ContentDisplay (a Sprite) that contains a Video object to which the NetStream is attached. This ContentDisplay Sprite can be accessed immediately; you do not need to wait for the video to load.
public function get content():*| duration | property |
duration:Number [read-only] The duration (in seconds) of the video. This value is only accurate AFTER the metaData has been received and the INIT event has been dispatched.
public function get duration():Number| metaData | property |
public var metaData:ObjectThe metaData that was received from the video (contains information about its width, height, frame rate, etc.). See Adobe's docs for information about a NetStream's onMetaData callback.
| netStream | property |
netStream:NetStream [read-only] The NetStream object used to load the video
public function get netStream():NetStream| playProgress | property |
playProgress:NumberA value between 0 and 1 describing the playback progress where 0 means the virtual playhead is at the very beginning of the video, 0.5 means it is at the halfway point and 1 means it is at the end of the video.
public function get playProgress():Number public function set playProgress(value:Number):void| rawContent | property |
rawContent:Video [read-only] The Video object to which the NetStream was attached (automatically created by VideoLoader internally)
public function get rawContent():Video| soundTransform | property |
soundTransform:SoundTransformThe soundTransform of the NetStream associated with the VideoLoader (this gets refreshed when the VideoLoader is unloaded or reloaded).
public function get soundTransform():SoundTransform public function set soundTransform(value:SoundTransform):void| stageVideo | property |
stageVideo:Object By default, the NetStream gets attached to a Video object, but if you want to use StageVideo in Flash, you can define the stageVideo object and VideoLoader will attach its NetStream to that StageVideo instance instead of the regular Video instance (which is the rawContent). Please read Adobe's docs regarding StageVideo to understand the tradeoffs and limitations. Note: the data type is Object instead of StageVideo in order to make VideoLoader compatible with Flash Player 9 and 10. Otherwise, you wouldn't be able to publish to those players because StageVideo was introduced in a later version.
public function get stageVideo():Object public function set stageVideo(value:Object):void| videoPaused | property |
videoPaused:Boolean The playback status of the video: true if the video's playback is paused, false if it isn't.
public function get videoPaused():Boolean public function set videoPaused(value:Boolean):void| videoTime | property |
videoTime:NumberThe time (in seconds) at which the virtual playhead is positioned on the video. For example, if the virtual playhead is currently at the 3-second position (3 seconds from the beginning), this value would be 3.
public function get videoTime():Number public function set videoTime(value:Number):void| volume | property |
volume:NumberThe volume of the video (a value between 0 and 1).
public function get volume():Number public function set volume(value:Number):void| VideoLoader | () | Constructor |
public function VideoLoader(urlOrRequest:*, vars:Object = null)Constructor
ParametersurlOrRequest:* — The url (String) or URLRequest from which the loader should get its content.
| |
vars:Object (default = null) — An object containing optional configuration details. For example: new VideoLoader("video/video.flv", {name:"myVideo", onComplete:completeHandler, onProgress:progressHandler}).
The following special properties can be passed into the constructor via the
|
See also
| _seek | () | method |
protected function _seek(time:Number):void
Parameters
time:Number |
| addASCuePoint | () | method |
public function addASCuePoint(time:Number, name:String, parameters:Object = null):Object
Adds an ActionScript cue point. Cue points are only triggered when the video is playing and passes
the cue point's position in the video (in the forwards direction - they are not triggered when you skip
to a previous time in the video with gotoVideoTime()).
For example, to add a cue point named "coolPart" at the 5-second point of the video, do:
myVideoLoader.addASCuePoint(5, "coolPart", {message:"This is a cool part.", id:5});
myVideoLoader.addEventListener(VideoLoader.VIDEO_CUE_POINT, cuePointHandler);
function cuePointHandler(event:LoaderEvent):void {
trace("hit cue point " + event.data.name + ", message: " + event.data.parameters.message);
}
Parameters
time:Number — The time (in seconds) at which the cue point should be placed in the video.
| |
name:String — The name of the cue point. It is acceptable to have multiple cue points with the same name.
| |
parameters:Object (default = null) — An object containing any data that you want associated with the cue point. For example, {message:"descriptive text", id:5}. This data can be retrieved in the VIDEO_CUE_POINT handler via the LoaderEvent's data property like event.data.parameters
|
Object — The cue point that was added
|
See also
| addEventListener | () | method |
override public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Parameters
type:String | |
listener:Function | |
useCapture:Boolean (default = false) | |
priority:int (default = 0) | |
useWeakReference:Boolean (default = false) |
| auditSize | () | method |
override public function auditSize():void
Attempts loading just enough of the content to accurately determine the bytesTotal
in order to improve the accuracy of the progress property. Once the
bytesTotal has been determined or the auditSize() attempt fails due
to an error (typically IO_ERROR or SECURITY_ERROR), the auditedSize property will be
set to true. Auditing the size opens a URLStream that will be closed
as soon as a response is received.
| clearVideo | () | method |
public function clearVideo():void Clears the video from the rawContent (the Video object). This also works around a bug in Adobe's Video class that prevents clear() from working properly in some versions of the Flash Player (https://bugs.adobe.com/jira/browse/FP-178). Note that this does not detatch the NetStream - it simply deletes the currently displayed image/frame, so you'd want to make sure the video is paused or finished before calling clearVideo().
| getCuePointTime | () | method |
public function getCuePointTime(name:String):Number
Finds a cue point by name and returns its corresponding time (where it is positioned in the video).
All cue points will be included in the search (cue points embedded into the video when it was encoded
as well as cue points that were added with addASCuePoint()).
Parameters
name:String — The name of the cue point
|
Number — The cue point's time (NaN if no cue point was found with the specified name)
|
See also
| gotoVideoCuePoint | () | method |
public function gotoVideoCuePoint(name:String, forcePlay:Boolean = false, skipCuePoints:Boolean = true):Number
Attempts to jump to a certain cue point (either a cue point that was embedded in the
video itself when it was encoded or a cue point that was added via addASCuePoint()).
If the video hasn't downloaded enough to get to the cue point or if there is no keyframe at that
point in the video, it will get as close as possible. For example, to jump to a cue point
named "highlight1" and play from there:
loader.gotoVideoCuePoint("highlight1", true);
Parameters
name:String — The name of the cue point
| |
forcePlay:Boolean (default = false) — If true, the video will resume playback immediately after seeking to the new position.
| |
skipCuePoints:Boolean (default = true) — If true (the default), any cue points that are positioned between the current videoTime and the destination cue point will be ignored when moving to the new videoTime. In other words, it is like a record player that has its needle picked up, moved, and dropped into a new position rather than dragging it across the record, triggering the various cue points (if any exist there). IMPORTANT: cue points are only triggered when the time advances in the forward direction; they are never triggered when rewinding or restarting.
|
Number — The cue point's time (NaN if the cue point wasn't found)
|
See also
| gotoVideoTime | () | method |
public function gotoVideoTime(time:Number, forcePlay:Boolean = false, skipCuePoints:Boolean = true):NumberAttempts to jump to a certain time in the video. If the video hasn't downloaded enough to get to the new time or if there is no keyframe at that time value, it will get as close as possible. For example, to jump to exactly 3-seconds into the video and play from there:
loader.gotoVideoTime(3, true);
The VideoLoader's videoTime will immediately reflect the new time, but PLAY_PROGRESS
event won't be dispatched until the NetStream's time renders at that spot (which can take a frame or so).
Parameters
time:Number — The time (in seconds, offset from the very beginning) at which to place the virtual playhead on the video.
| |
forcePlay:Boolean (default = false) — If true, the video will resume playback immediately after seeking to the new position.
| |
skipCuePoints:Boolean (default = true) — If true (the default), any cue points that are positioned between the current videoTime and the destination time (defined by the time parameter) will be ignored when moving to the new videoTime. In other words, it is like a record player that has its needle picked up, moved, and dropped into a new position rather than dragging it across the record, triggering the various cue points (if any exist there). IMPORTANT: cue points are only triggered when the time advances in the forward direction; they are never triggered when rewinding or restarting.
|
Number |
See also
| pauseVideo | () | method |
public function pauseVideo(event:Event = null):voidPauses playback of the video.
Parameters
event:Event (default = null) — An optional Event which simply makes it easier to use the method as a handler for mouse clicks or other events.
|
See also
| playVideo | () | method |
public function playVideo(event:Event = null):voidPlays the video (if the buffer isn't full yet, playback will wait until the buffer is full).
Parameters
event:Event (default = null) — An optional Event which simply makes it easier to use the method as a handler for mouse clicks or other events.
|
See also
| removeASCuePoint | () | method |
public function removeASCuePoint(timeNameOrCuePoint:*):Object
Removes an ActionScript cue point that was added with addASCuePoint(). If multiple ActionScript
cue points match the search criteria, only one is removed. To remove all, call this function repeatedly in a
loop with the same parameters until it returns null.
Parameters
timeNameOrCuePoint:* — The time, name or cue point object that should be removed. The method removes the first cue point that matches the criteria.
|
Object — The cue point that was removed (or null if none were found that match the criteria)
|
See also
| repeatCount | () | method |
public function repeatCount(value:int = 0):*
Sets or gets the current repeat count (how many times the video has repeated, as determined
by the "repeat" special property that was passed into the constructor). If you pass
a value to the function, it acts as a setter, and if you omit the parameter, it acts as a getter
and returns the current value. For example, if the video was set to repeat 5 times and it is currently
in the middle of its 3rd time playing, repeatCount() will return 2 because it has already
finished playing twice completely.
Parameters
value:int (default = 0) — the value that should be assigned to the current repeat count (or if you omit this parameter, the current repeat count will be returned)
|
* — If the value parameter is omitted, it will return the current repeat count (how many times it has completely played and looped back to the beginning). If the function is used as a setter, the VideoLoader instance itself is returned in order to make chaining easier.
|
| httpStatus | Event |
com.greensock.events.LoaderEvent Dispatched when the loader's httpStatus value changes.
| netStatus | Event |
com.greensock.events.LoaderEvent Dispatched when the netStream dispatches a NET_STATUS event.
| PLAY_PROGRESS | Constant |
public static const PLAY_PROGRESS:String = playProgressEvent type constant for when the playback progresses (only dispatched when the video is playing).
| VIDEO_BUFFER_EMPTY | Constant |
public static const VIDEO_BUFFER_EMPTY:String = videoBufferEmptyEvent type constant for when the video's buffer is empty.
| VIDEO_BUFFER_FULL | Constant |
public static const VIDEO_BUFFER_FULL:String = videoBufferFullEvent type constant for when the video's buffer is full.
| VIDEO_COMPLETE | Constant |
public static const VIDEO_COMPLETE:String = videoCompleteEvent type constant for when the video completes.
| VIDEO_CUE_POINT | Constant |
public static const VIDEO_CUE_POINT:String = videoCuePointEvent type constant for when the video reaches a cue point in the playback of the NetStream.
| VIDEO_PAUSE | Constant |
public static const VIDEO_PAUSE:String = videoPauseEvent type constant for when the video is paused.
| VIDEO_PLAY | Constant |
public static const VIDEO_PLAY:String = videoPlayEvent type constant for when the video begins or resumes playing. If the buffer isn't full yet when VIDEO_PLAY is dispatched, the video will wait to visually begin playing until the buffer is full. So VIDEO_PLAY indicates when the NetStream received an instruction to play, not necessarily when it visually begins playing.