DoubleClick Studio AS3 API Reference

class com.google.ads.studio.video.VideoPlayer

Extends com.google.ads.studio:EnabledComponent

Video Player component that enables the user to play a video with metric reporting. This component is as bare bones as possible and supports only one single progressive video. No convenience callbacks are available and the video does not do any smart buffering.

For more information, see Video Player.

The following diagram details the Video Player architecture:

videoPlayerArchitecture

Note: If you'd like to play video without the added weight of using a component, this component is a wrapper around the VideoController API.

Controlling video:
   import com.google.ads.studio.HtmlEnabler;
   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);
       });
   

Expand Events

Constructors

Expand
VideoPlayer(registeredByConfigurable:Boolean=false) : void

Constructs a video player.

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:VideoPlayer

getCurrentVideoController() : VideoController

Gets a reference to the video controller.

     import com.google.ads.studio.video.VideoController;
      
     // Get a reference to the current video.
     var videoController:VideoController =
         videoComponentInstance.getCurrentVideoController();
     

getElapsedSeconds() : Number

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

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%.

getReportingIdentifier() : String

Returns the reporting identifier.

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.

     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);
     

isVideoMuted() : Boolean

Indicates whether the current video controller is muted.

isVideoPaused() : Boolean

Indicates whether the current video controller is paused.

isVideoPlaying() : Boolean

Returns 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.

Expand
pause(alwaysPause:Boolean=false) : void

Pauses the current video controller.

play() : void

Plays the current video controller.

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 on completion of the video.

Expand
setPrimary(primary:Boolean) : void

Sets whether this video player is the primary video player. Only one video player should ever have this option enabled at one time.

Expand
setReportDuration(reportDuration:Boolean) : void

Sets whether this video player should report its duration as the VPAID duration. The option only takes affect if the video player is also the primary video player.

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.VideoController;
      
     // Get a reference to the current video.
     var videoController:VideoController =
         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