DoubleClick Studio AS3 API Reference

class com.google.ads.studio.video.VideoPlayerAdvanced

Extends com.google.ads.studio:EnabledComponent

Video Player Advanced component that enables the user to play one or more videos that get tracked. This component is a wrapper for the Playlist class that offers settings that can be managed in DART.

For more information, see Video Player Advanced.

The following diagram details the Video Player Advanced architecture:

videoPlayerAdvancedArchitecture

Control the current video:
   import com.google.ads.studio.HtmlEnabler;
   import com.google.ads.studio.events.StudioEvent;
   import com.google.ads.studio.events.StudioVideoEvent;
   import flash.events.MouseEvent;
    
   HtmlEnabler.getInstance().init(this);
    
   videoPlayer.addEventListener(
       StudioVideoEvent.STATE_CHANGE,
       function (event:StudioVideoEvent):void {
         if (videoPlayer.isVideoStopped()) {
           postVideoAnimation.play();
         } else {
           postVideoAnimation.gotoAndStop(1);
         }
       });
    
   // The following listeners are for instances of buttons on the stage.
   playBtn.addEventListener(
       MouseEvent.CLICK,
       function (event:MouseEvent):void {
         videoPlayer.play();
       });
    
   pauseBtn.addEventListener(
       MouseEvent.CLICK,
       function (event:MouseEvent):void {
         videoPlayer.pause();
       });
    
   stopBtn.addEventListener(
       MouseEvent.CLICK,
       function (event:MouseEvent):void {
         videoPlayer.stop();
       });
    
   muteBtn.addEventListener(
       MouseEvent.CLICK,
       function (event:MouseEvent):void {
         videoPlayer.mute();
       });
    
   unmuteBtn.addEventListener(
       MouseEvent.CLICK,
       function (event:MouseEvent):void {
         videoPlayer.unmute();
       });
    
   seekNearEndBtn.addEventListener(
       MouseEvent.CLICK,
       function (event:MouseEvent):void {
         videoPlayer.seek(
             videoPlayer.getTotalSeconds() - 5);
       });
    
   function setCurrentVideoLabel():void {
     videoNumberTxt.text = (videoPlayer.getCurrentVideoIndex() + 1) + " / " +
         videoPlayer.getNumberOfVideos();
   }
    
   videoPlayer.addEventListener(
       StudioEvent.INIT,
       function (event:StudioEvent):void {
         // Gets dispatched after component has read its properties
         // and created videos entries.
         setCurrentVideoLabel();
       });
    
   videoPlayer.addEventListener(
       StudioEvent.UPDATE,
       function (event:StudioEvent):void {
         // Gets dispatched when video is changed.
         setCurrentVideoLabel();
       });
    
   previousBtn.addEventListener(
       MouseEvent.CLICK,
       function (event:MouseEvent):void {
         videoPlayer.previous();
       });
    
   nextBtn.addEventListener(
       MouseEvent.CLICK,
       function (event:MouseEvent):void {
         videoPlayer.next();
       });
   

Advanced Usage:

You can programmatically set the reporting identifier and URL of a video. This is supported only before the video controller attempts the load. For immediate play, set the player to "wait for command" and then use the API to start playing after you have finished setting the new values.
   // Make sure the video player is set to wait for command.
    
   import com.google.ads.studio.video.EnhancedVideoController;
    
   // Get a reference to the current video.
   var videoController:EnhancedVideoController =
       videoPlayer.getCurrentVideoController();
    
   // Set the reporting identifier.
   videoController.setReportingIdentifier("new identifier");
    
   // Drill down to the first set of URL entries and set the high URL.
   videoController.getVideoEntries()[0].setHigh("newVideo.flv");
    
   // Kick off and start playing.
   videoPlayer.getPlaylist().start(true); // trackAsAutoPlay
   
Add an additional playlist item:
   import com.google.ads.studio.video.EnhancedVideoController;
   import com.google.ads.studio.video.VideoEntry;
    
   // Create the new video item.
   var videoController:EnhancedVideoController =
       new EnhancedVideoController();
   // Set the reporting identifier.
   videoController.setReportingIdentifier("new identifier");
    
   // Create a set of URL entries.
   var videoEntry:VideoEntry =
       new VideoEntry("high.flv", "mid.flv", "low.flv");
    
   // Attach the URL entries to the video item.
   videoController.addVideoEntry(videoEntry);
   // Add the video item to the end of the playlist.
   videoPlayer.getPlaylist().addVideoController(videoController);
   // Start the playlist.
   videoPlayer.getPlaylist().start(true); // trackAsAutoPlay
   

Expand Events

Constructors

Instance Methods

Defined in: com.google.ads.studio:EnabledComponent

getEnabler() : Object
isInitialized() : Boolean

Returns whether the component has initialized.

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

getCurrentVideoController() : EnhancedVideoController

Gets the current playing video controller.

getCurrentVideoIndex() : int

Gets the index of the current playing VideoController.

getElapsedSeconds() : Number

Returns the elapsed time in seconds of the current video controller.

getNumberOfVideos() : int

Gets the number of VideoControllers that have been added to the playlist.

getPercentLoaded() : Number

Indicates the percent of video loaded in the current video controller as a number between 0 and 1.

Note: Because streaming videos will only cache the number of seconds stated in the buffer length, it's more accurate for the user to believe that the entire video is loaded as they can seek to the non-cached portion of the video. Thus, this method will return 100% if the video is streaming. Also, if the content length header is missing from the HTTP response, bytesTotal will always be 0 so we assume the entire video has loaded and report 100%.

getPlaylist() : Playlist

Gets the playlist object.

getTotalSeconds() : Number

Returns the total duration in seconds of the current video. In order to get this value, you must wait for the StudioVideoEvent.DURATION event.

getVideoObject() : Video

Gets the video object.

isVideoMuted() : Boolean

Indicates whether the current video controller is muted.

isVideoPaused() : Boolean

Indicates whether the current video controller is paused.

isVideoPlaying() : Boolean

Indicates whether the current video controller is playing.

isVideoStopped() : Boolean

Indicates whether the current video controller is stopped or complete.

mute() : void

Mutes the current video controller.

next() : EnhancedVideoController

Goes to the next video (EnhancedVideoController) in the playlist or back to the first if the current video is the last in the playlist.

Expand
pause(alwaysPause:Boolean=false) : void

Pauses the current video controller.

play() : void

Plays the current video controller.

previous() : EnhancedVideoController

Goes to the previous video (EnhancedVideoController) in the playlist or to the last if the current video is the first in the playlist.

Expand
seek(time:Number) : void

Seeks the playhead to a particular time in seconds.

Expand
setCloseOnComplete(closeOnComplete:Boolean) : void

Sets whether the creative should close after a video in this VideoPlayer completes.

Expand
setPlaylist(playlist: Playlist) : void

Sets the playlist object.

Expand
setPrimary(primary:Boolean) : void

Sets whether the videos in this VideoPlayer should be the primary videos.

Expand
setReportDuration(reportDuration:Boolean) : void

Sets whether the videos in this VideoPlayer should report their durations as the VPAID durations.

Expand
skipTo(index:int) : EnhancedVideoController

Skips directly to the index of one of the VideoControllers and starts playing it.

stop() : void

Stops the current video controller.

unload() : void

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

     import com.google.ads.studio.video.EnhancedVideoController;
      
     // Get a reference to the current video.
     var videoController:EnhancedVideoController =
         videoComponentInstance.getCurrentVideoController();
      
     var endFrameClickHandler:Function = function(event:MouseEvent):void {
       videoController.unload();
     };
     endFrameButton.addEventListener(MouseEvent.CLICK, endFrameClickHandler);
     

unmute() : void

Unmutes the current video controller.

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