DoubleClick Studio AS3 API Reference

class com.google.ads.studio.video.EnhancedVideoController

Extends com.google.ads.studio.video:VideoController

An enhanced video controller. This controller provides additional helper methods as well as the ability to smart buffer a video before playing it. As we expose the checkPolicyFile attribute of the NetStream attribute, this class only supports Flash Player 9; if this functionality is not required the minimum compatible Flash player version is 7.

Constants

NameValueDescription
VIDEO_COMPLETE_HIDE_VIDEOvideoCompleteHideVideo

Hide the video when it has completed.

VIDEO_COMPLETE_SHOW_FIRST_FRAMEvideoCompleteShowFirstFrame

Stay on the first frame of the video when it has completed.

VIDEO_COMPLETE_SHOW_LAST_FRAMEvideoCompleteShowLastFrame

Stay on the last frame of the video when it has completed.

Expand Events

Constructors

EnhancedVideoController()

Creates an EnhancedVideoController.

Instance Methods

Defined in: com.google.ads.studio.video:VideoController

Expand
addVideoEntry(videoEntry: VideoEntry) : void

Add a video entry to the video controller. The order in which these are added is the order in which they'll be attempted. The first video entry is pre-created and can either be added (which replaces the first dummy) or edited via getVideoEntries()[0].setHigh("foo.flv"); . These example code blocks are equivalent.

     import com.google.ads.studio.video.SmartStreamingConnection;
     import com.google.ads.studio.video.VideoController;
     import com.google.ads.studio.video.VideoEntry;
      
     var videoController:VideoController = new VideoController();
     videoController.setReportingIdentifier("my video");
     videoController.addVideoEntry(new VideoEntry(
         "streaming_high.flv",
         null, null,
         SmartStreamingConnection));
     videoController.addVideoEntry(new VideoEntry("progressive_high.flv"));
     
     import com.google.ads.studio.video.SmartStreamingConnection;
     import com.google.ads.studio.video.VideoController;
     import com.google.ads.studio.video.VideoEntry;
      
     var videoController:VideoController = new VideoController();
     videoController.setReportingIdentifier("my video");
     videoController.getVideoEntries()[0].setHigh("streaming_high.flv");
     videoController.getVideoEntries()[0].setConnectionType(
         SmartStreamingConnection);
     // Secondary video entries always needs to be added.
     videoController.addVideoEntry(new VideoEntry("progressive_high.flv"));
     

attachAudioAndVideo() : void

After the netstream object is available, this attaches the video and audio to netstream object.

cloneWithBasicProperties() : VideoController

Clones a video controller with its basic properties such as buffer time and reporting ID. Note that this does NOT copy any video entries or any other properties.

getAudioChannel() : AudioChannel

Gets the audio channel.

     import com.google.ads.studio.audio.AudioChannel;
      
     var unmuteClickHandler:Function = function(event:MouseEvent):void {
       var audioChannel:AudioChannel = videoComponentInstance.
           getCurrentVideoController().getAudioChannel();
       audioChannel.MAX_VOLUME;
     };
     unmuteButton.addEventListener(MouseEvent.CLICK, unmuteClickHandler);
     

getBufferTime() : Number

Gets the set buffer time.

     import com.google.ads.studio.video.VideoController;
     import com.google.ads.studio.events.StudioVideoEvent;
      
     var videoController:VideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var videoBufferedHandler:Function = function(
         event:StudioVideoEvent):void {
       trace("Video's buffer time is " +
           videoController.getBufferTime() + ".");
     };
     videoComponentInstance.addEventListener(
         StudioVideoEvent.BUFFERED,
         videoBufferedHandler);
     

getNetConnection() : NetConnection

Gets the current netconnection.

     import com.google.ads.studio.video.VideoController;
     import com.google.ads.studio.events.StudioVideoEvent;
      
     var videoController:VideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var netConnectionAvailableHandler:Function = function(
         event:StudioVideoEvent):void {
       trace("Current Net Connection is " +
           videoController.getNetConnection() + ".");
     };
     videoController.addEventListener(
         StudioVideoEvent.NET_CONNECTION_AVAILABLE,
         netConnectionAvailableHandler);
     

getNetStream() : NetStream

Gets current the netstream object.

     import com.google.ads.studio.video.VideoController;
     import com.google.ads.studio.events.StudioVideoEvent;
      
     var videoController:VideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var onNetStreamAvailableHandler:Function = function(
         event:StudioVideoEvent):void {
       trace("Current Net Stream object is " +
           videoController.getNetStream() + ".");
     };
     videoController.addEventListener(
         StudioVideoEvent.NET_STREAM_AVAILABLE,
         netStreamAvailableHandler);
     

getNumberOfVideoEntries() : Number

Gets the number of video entries.

     import com.google.ads.studio.video.VideoController;
     import com.google.ads.studio.events.StudioVideoEvent;
      
     var videoController:VideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var videoBufferedHandler:Function = function(
         event:StudioVideoEvent):void {
       trace("The number of video entry(ies) is(are) " +
           videoController.getNumberOfVideoEntries() + ".");
     };
     videoComponentInstance.addEventListener(
         StudioVideoEvent.BUFFERED,
         videoBufferedHandler);
     

getPlayerState() : AbstractPlayerState

Gets the current player state.

     import com.google.ads.studio.video.VideoController;
     import com.google.ads.studio.events.StudioVideoEvent;
      
     var videoController:VideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var enterFrameHandler:Function = function(event:Event):void {
       trace("The current player state is " +
           videoController.getPlayerState() + ".");
     };
     this.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
     

getReportingIdentifier() : String

Gets the video reporting identifier.

     import com.google.ads.studio.video.VideoController;
     import com.google.ads.studio.events.StudioVideoEvent;
      
     var videoController:VideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var videoBufferedHandler:Function = function(
         event:StudioVideoEvent):void {
       trace("The video reporting identifier is " +
           videoController.getReportingIdentifier() + ".");
     };
     videoComponentInstance.addEventListener(
         StudioVideoEvent.BUFFERED,
         videoBufferedHandler);
     

getVideoConnection() : AbstractVideoConnection

Gets the current video connection.

     import com.google.ads.studio.video.VideoController;
     import com.google.ads.studio.events.StudioVideoEvent;
      
     var videoController:VideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var videoBufferedHandler:Function = function(
         event:StudioVideoEvent):void {
       trace("The current Video connection is " +
           videoController.getVideoConnection() + ".");
     };
     videoComponentInstance.addEventListener(
         StudioVideoEvent.BUFFERED,
         videoBufferedHandler);
     

getVideoEntries() : Array

Gets the currently added video entries.

     import com.google.ads.studio.video.VideoController;
     import com.google.ads.studio.events.StudioVideoEvent;
      
     var videoController:VideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var videoBufferedHandler:Function = function(
         event:StudioVideoEvent):void {
       var videoEntries:Array = videoController.getVideoEntries();
       for (var i = 0; i < videoEntries.length; i++) {
         trace("Video Entry #" + i + "is " + videoEntries[i]);
       }
     };
     videoComponentInstance.addEventListener(
         StudioVideoEvent.BUFFERED,
         videoBufferedHandler);
     

getVideoObject() : Video

Gets the video object.

     import com.google.ads.studio.video.VideoController;
     import com.google.ads.studio.events.StudioVideoEvent;
      
     // Get a reference to the current video.
     var videoController:VideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var videoBufferedHandler:Function = function(
         event:StudioVideoEvent):void {
       var videoObject:Video = videoController.getVideoObject();
     };
     videoComponentInstance.addEventListener(
         StudioVideoEvent.BUFFERED,
         videoBufferedHandler);
     

mute() : void

Mutes the audio channel associated to the playing video.

     var muteClickHandler:Function = function(event:MouseEvent):void {
       videoController.mute();
     };
     muteButton.addEventListener(MouseEvent.CLICK, muteClickHandler);
     

Expand
pause(alwaysPause:Boolean=false) : void

Pauses the video.

     var pauseClickHandler:Function = function(event:MouseEvent):void {
       videoController.pause();
     };
     pauseButton.addEventListener(MouseEvent.CLICK, pauseClickHandler);
     

Expand
play(trackAsAutoPlay:Boolean=false) : void

Plays the video.

     var playClickHandler:Function = function(event:MouseEvent):void {
       videoController.play();
     };
     playButton.addEventListener(MouseEvent.CLICK, playClickHandler);
     

replay() : void

Replays the video.

     var replayClickHandler:Function = function(event:MouseEvent):void {
       videoController.replay();
     };
     replayButton.addEventListener(MouseEvent.CLICK, replayClickHandler);
     

Expand
seek(time:Number) : void

Seeks the playhead to a particular time in seconds.

     var seekClickHandler:Function = function(event:MouseEvent):void {
       videoController.seek(10);
     };
     seekButton.addEventListener(MouseEvent.CLICK, seekClickHandler);
     

Expand
setBufferTime(seconds:Number) : void

Sets the amount of time to buffer.

     var timeInSeconds:int = 1;
     videoController.setBufferTime(timeInSeconds);
     

Expand
setCloseOnComplete(closeOnComplete:Boolean) : void

Sets whether the creative should close on completion of this video.

Expand
setEnabler(enabler:Object) : void

Sets the Enabler.

Expand
setPrimary(isPrimary:Boolean) : void

Sets whether this is the primary video controller.

Expand
setReportDuration(reportDuration:Boolean) : void

Sets whether this controller should report its duration.

Expand
setReportingIdentifier(reportingIdentifier:String) : void

Sets the reporting identifier for the videos to report as.

     videoController.setReportingIdentifier("Video_1");
     

Expand
setVideoObject(video:flash.media:Video) : void

Sets the video object to display the video.

     import com.google.ads.studio.video.VideoController;
     import com.google.ads.studio.video.VideoEntry;
      
     var videoController:VideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var addVideoClickHandler:Function = function(event:MouseEvent):void {
       var videoEntry:VideoEntry =
           new VideoEntry("broadband_video.flv", "midband_video.flv",
               "narrowband_video.flv");
       videoController = new VideoController();
       videoController.setReportingIdentifier("new_video");
       videoController.addVideoEntry(videoEntry);
       videoController.setVideoObject(vidPlayerInstance.getVideoObject());
       videoController.play();
     };
     addVideoButton.addEventListener(MouseEvent.CLICK, addVideoClickHandler);
     

stop() : void

Stops the video. The current implementation for stop is to pause and seek the playhead to 0.

     var stopClickHandler:Function = function(event:MouseEvent):void {
       videoController.stop();
     };
     stopButton.addEventListener(MouseEvent.CLICK, stopClickHandler);
     

unload() : void

Unloads the video controller and preps it for garbage collection as well as possible.

     var unloadClickHandler:Function = function(event:MouseEvent):void {
       videoController.unload();
     };
     unloadButton.addEventListener(MouseEvent.CLICK, unloadClickHandler);
     

unmute() : void

Unmutes the audio channel associated to the playing video.

     var unmuteClickHandler:Function = function(event:MouseEvent):void {
       videoController.unmute();
     unmuteButton.addEventListener(MouseEvent.CLICK, unmuteClickHandler);
     

Defined in com.google.ads.studio.video:EnhancedVideoController

Expand
addAllEventsListener(handler:Function) : void

Convenience method that adds a handler to all video events.

Expand
buffer(playAfterBuffer:Boolean=false, trackAsAutoPlay:Boolean=false) : void

Buffers the video and optionally plays it after buffering. This method can only be called when the player is in an idle state.

     import com.google.ads.studio.video.EnhancedVideoController;
     import com.google.ads.studio.events.StudioVideoEvent;
      
     var videoController:EnhancedVideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var videoComponentInitHandler:Function = function(
         event:StudioEvent):void {
       videoController.buffer(true);
     };
     videoComponentInstance.addEventListener(
         StudioEvent.INIT,
         videoComponentInitHandler);
     

getDuration() : Number

Gets the duration of the current video.

     import com.google.ads.studio.video.EnhancedVideoController;
     import com.google.ads.studio.events.StudioVideoEvent;
      
     var videoController:EnhancedVideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var videoBufferedHandler:Function = function(
         event:StudioVideoEvent):void {
       trace("Current video's duration is " +
           videoController.getDuration() + ".");
     };
     videoComponentInstance.addEventListener(
         StudioVideoEvent.BUFFERED,
         videoBufferedHandler);
     

getElapsed() : Number

The elapsed seconds of the video.

     import com.google.ads.studio.video.EnhancedVideoController;
     import com.google.ads.studio.events.StudioVideoEvent;
      
     var videoController:EnhancedVideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var videoPlayHandler:Function = function(event:StudioVideoEvent):void {
       trace("Video's elapsed seconds is " +
           videoController.getElapsed() + ".");
     };
     videoController.addEventListener(
         StudioVideoEvent.PLAY,
         videoPlayHandler);
     

getPercentLoaded() : Number

Gets the percent the video has loaded. Note: If the content-length header is missing from the FLV this method returns the playhead time and the amount of video buffered over the duration of the video.

     import com.google.ads.studio.video.EnhancedVideoController;
     import com.google.ads.studio.events.StudioVideoEvent;
      
     var videoController:EnhancedVideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var trackPercentLoaded:Function = function(event:Event):void {
       trace("Video's percent loaded is " +
           videoComponentInstance.getPercentLoaded() + "%.");
     };
      
     var videoBufferedHandler:Function = function(
         event:StudioVideoEvent):void {
       this.addEventListener(Event.ENTER_FRAME, trackPercentLoaded);
     };
     videoComponentInstance.addEventListener(
         StudioVideoEvent.BUFFERED,
         videoBufferedHandler);
     

getVolume() : Number

The volume of the audio.

     import com.google.ads.studio.video.EnhancedVideoController;
     import com.google.ads.studio.events.StudioVideoEvent;
      
     var videoController:EnhancedVideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var videoBufferedHandler:Function = function(
         event:StudioVideoEvent):void {
       trace("Audio's volume is " + videoController.getVolume() + ".");
     };
     videoComponentInstance.addEventListener(
         StudioVideoEvent.BUFFERED,
         videoBufferedHandler);
     

isCurrentVideoConnectionHttp() : Boolean

Indicates whether the current video connection is over HTTP.

     import com.google.ads.studio.video.EnhancedVideoController;
     import com.google.ads.studio.events.StudioVideoEvent;
      
     var videoController:EnhancedVideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var videoBufferedHandler:Function = function(
         event:StudioVideoEvent):void {
       if (videoController.isCurrentVideoConnectionHttp()) {
         trace("Current video connection is Http.");
       }
     };
     videoComponentInstance.addEventListener(
         StudioVideoEvent.BUFFERED,
         videoBufferedHandler);
     

Expand
play(trackAsAutoPlay:Boolean=false) : void

Plays the video.

     var playClickHandler:Function = function(event:MouseEvent):void {
       videoController.play();
     };
     playButton.addEventListener(MouseEvent.CLICK, playClickHandler);
     

Expand
removeAllEventsListener(handler:Function) : void

Convenience method that removes a handler to all video events.

Expand
setCheckPolicyFile(checkPolicyFile:Boolean) : void

Sets whether to check the policy file when connecting to a video. This allows the user to capture BitmapDatas of videos on a different domain from the SWF's if the crossdomain policy file allows.

     import com.google.ads.studio.video.EnhancedVideoController;
      
     var videoController:EnhancedVideoController =
         videoComponentInstance.getCurrentVideoController();
     videoController.setCheckPolicyFile(true);
     

Expand
setPostBufferCallback(callback:Function) : void

Convenience method to add a callback to invoke when the video has finished buffering.

     import com.google.ads.studio.video.EnhancedVideoController;
      
     var videoController:EnhancedVideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var bufferCallBack:Function = function():void {
       trace("Video has buffered.");
     };
     videoController.setPostBufferCallback(bufferCallBack);
     

Expand
setVideoCompleteCallback(callback:Function) : void

Sets the callback to invoke when the video has completed.

     import com.google.ads.studio.video.EnhancedVideoController;
      
     var videoController:EnhancedVideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var videoCompleteCallBack:Function = function():void {
       trace("Video has completed playing.");
     };
     videoController.setVideoCompleteCallback(videoCompleteCallBack);
     

Expand
setVideoCompleteDisplay(option:String) : void

Sets what to display when the video has completed. The options are: EnhancedVideoController.VIDEO_COMPLETE_SHOW_LAST_FRAME, EnhancedVideoController.VIDEO_COMPLETE_SHOW_FIRST_FRAME, or EnhancedVideoController.VIDEO_COMPLETE_HIDE_VIDEO. The default setting is EnhancedVideoController.VIDEO_COMPLETE_HIDE_VIDEO.

     import com.google.ads.studio.video.EnhancedVideoController;
     import com.google.ads.studio.events.StudioVideoEvent;
      
     var videoController:EnhancedVideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var videoBufferedHandler:Function = function(
         event:StudioVideoEvent):Void {
       videoController.setVideoCompleteDisplay(
           EnhancedVideoController.VIDEO_COMPLETE_SHOW_FIRST_FRAME);
       // For other Video complete display options:
       // videoController.setVideoCompleteDisplay(
       //     EnhancedVideoController.VIDEO_COMPLETE_SHOW_LAST_FRAME);
       // videoController.setVideoCompleteDisplay(
       //     EnhancedVideoController.VIDEO_COMPLETE_HIDE_VIDEO);
     };
     videoComponentInstance.addEventListener(
         StudioVideoEvent.BUFFERED,
         videoBufferedHandler);
     

Expand
setVolume(volume:Number) : void

Sets the volume of this video.

     import com.google.ads.studio.video.EnhancedVideoController;
      
     var videoController:EnhancedVideoController =
         videoComponentInstance.getCurrentVideoController();
     var volume:Number = 0;
      
     var volumeDownClickHandler:Function = function(event:MouseEvent):void {
       volume = Math.max(0, volume - .1);
       videoController.setVolume(volume);
     };
     volumeDownButton.addEventListener(
         MouseEvent.CLICK,
         volumeDownClickHandler);
      
     var volumeUpClickHandler:Function = function(event:MouseEvent):void {
       volume = Math.min(1, volume + .1);
       videoController.setVolume(volume);
     };
     volumeUpButton.addEventListener(MouseEvent.CLICK, volumeUpClickHandler);
     

Back to top

  1. com.google.ads.studio
    1. AssetLoader
    2. ContextualDiscovery
    3. F2fEnabler
    4. FullScreenButton
    5. HtmlEnabler
    6. ProxyEnabler
    7. VpaidEnabler
  1. com.google.ads.studio.configurable
    1. Configurable
  1. com.google.ads.studio.display
    1. StudioLoader
  1. com.google.ads.studio.events
    1. StudioEvent
    2. StudioVideoEvent
  1. com.google.ads.studio.expanding
    1. Expanding
  1. com.google.ads.studio.localconnect
    1. LocalConnectWrapper
  1. com.google.ads.studio.video
    1. ConfigurableVideoPlayer
    2. EnhancedVideoController
    3. PlayPauseButton
    4. Playlist
    5. Scrubber
    6. SoundToggleButton
    7. VideoController
    8. VideoEntry
    9. VideoPlayer
    10. VideoPlayerAdvanced
  1. com.google.ads.studio.vpaid
    1. VpaidTimer