From September, Flash will no longer be supported by Chrome. Prepare for the shift towards HTML5 by visiting our Flash to HTML5 help page

Check it out!

Video Component

  • Public Methods

    There are several public methods that can be used with the video player instance.

    setVideoSource - This method is used to change a video source in the video components runtime. The new video source will be started from the begining and will be in the play or pause state depending of the last video state. Mute and full screen will also be in the same state as they were in the previous video.

    public function setVideoSource(source:String):void

    Parameters
    source:String - Full link to the video source or asset id in "settings.xml".


    playVideo - This method is used to start video.

    public function playVideo():void

    stopVideo - This method is used to stop playing video.

    public function stopVideo():void

    pauseVideo - This method is used to pause video.

    public function pauseVideo():void

    mute - This method is used to mute video.

    public function mute():void

    unMute - This method is used to un-mute video.

    public function unMute():void

    setVolume - This method is used to change the video volume.

    public function setVolume(volume:Number):void

    Parameters
    volume:Number - A number from range [0,1], that indicates volume level.


     fullScreen - This method is used to change the video state. Depending on the parameter it will activate the full screen, or return to normal state.

    public function fullScreen(activate:Boolean):void

    Parameters
    activate:Boolean - Boolean value, that indicates whether to go to full screen (true), or to normal (false).


     rewind - This method is used to rewind the video. 

    public function rewind():void

     seekThis method is used to seek the video.

    public function seek(position:Number):void

    Parameters
    position:Number - A number from range [0.1], that indicates the video progress position to seek to.

  • Events

    AdformVideoEvent class is used to create and dispatch video events. User can do custom actions, interact and communicate with the video player through these events.

    AdformVideoEvent.PLAY
    Value: 'adformVideoEventPlay'
    Description: Whenever a video source starts playing.

    AdformVideoEvent.STOP
    Value: 'adformVideoEventStop'
    Description: Whenever a video source stops.

    AdformVideoEvent.PAUSE
    Value: 'adformVideoEventPause'
    Description: Whenever a video source starts pausing.

    AdformVideoEvent.LOAD_COMPLETE
    Value: 'adformVideoEventLoadComplete'
    Description: Dispatched when a video has loaded successfully.

    AdformVideoEvent.LOAD_PROGRESS
    Value: 'adformVideoEventLoadProgress'
    Description: Dispatched when data is received as the download operation progresses.

    AdformVideoEvent.PLAY_PROGRESS
    Value: 'adformVideoEventPlayProgress'
    Description: Dispatched when the video playing operation progresses.

    AdformVideoEvent.START_SEEK
    Value: 'adformVideoEventStartSeek'
    Description: Dispatched when a video has started seeking.

    AdformVideoEvent.END_SEEK
    Value: 'adformVideoEventEndSeek'
    Description: Dispatched when a video has stoped seeking.

    AdformVideoEvent.COMPLETE
    Value: 'adformVideoEventComplete'
    Description: Dispatched when a video was played successfully till the end.

    AdformVideoEvent.ON_CUE_POINT
    Value: 'adformVideoEventOnCuePoint'
    Description: Invoked when an embedded cue point is reached while playing a video file.

    AdformVideoEvent.ON_META_DATA
    Value: 'adformVideoEventOnMetaData'
    Description: Dispatched when the application receives descriptive information embedded in the video that is being played.

    AdformVideoEvent.SOUND_ON
    Value: 'adformVideoEventSoundOn'
    Description: Whenever the sound button has been toggled on.

    AdformVideoEvent.SOUND_OFF
    Value: 'adformVideoEventSoundOff'
    Description: Whenever the sound button has been toggled off.

    AdformVideoEvent.FULL_SCREEN_ON
    Value: 'adformVideoEventFullScreenOn'
    Description: Whenever a video enters the video fullscreen mode.

    AdformVideoEvent.FULL_SCREEN_OFF
    Value: 'adformVideoEventFullScreenOff'
    Description: Whenever a video leaves the video fullscreen mode.

    AdformVideoEvent.NET_CONNECTION_STATUS
    Value: 'adformVideoEventNetConnectionStatus'
    Description: Whenever the video net connection status changes (can be used only with streaming videos).

    AdformVideoEvent.SWITCH_VIDEO_SOURCE
    Value: 'adformVideoEventSwitchVideoSource'
    Description: Whenever a video source was switched.

    AdformVideoEvent.SET_VOLUME
    Value: 'adformVideoEventSetVolume'
    Description: This event is used to control volume of a video player. Also volume property must be set in the event constructor.

    AdformVideoEvent.POSTER_CLICK
    Value: 'adformVideoEventPosterClick'
    Description: Whenever a poster is clicked

  • Examples

    ActionScript2

    Example 1:

    import com.adform.events.AdformEventDispatcher;
    import com.adform.events.AdformVideoEvent;
    
    //event listener
    AdformEventDispatcher.addAdformEventListener(AdformVideoEvent.PLAY, eventHandler);
    function eventHandler(eObj:Object):Void
    {
    // custom code
    }
    
    //event dispatch
    this.btn.onRelease = function() : Void{
       AdformEventDispatcher.dispatchAdformEvent({type:AdformVideoEvent.PLAY, targetsArr:["adformVideoPlayer"]});
    }

    Example 2:

    import com.adform.events.AdformEventDispatcher;
    import com.adform.events.AdformVideoEvent;
    
    AdformEventDispatcher.addAdformEventListener(AdformVideoEvent.PLAY, callback);
    AdformEventDispatcher.addAdformEventListener(AdformVideoEvent.ON_META_DATA, callback);
    
    function callback(event:Object):Void {
        var response:String = '';
    
        switch (event.type) {
            case AdformVideoEvent.PLAY:
                response = 'Playing Video';
                break;
    
            case AdformVideoEvent.ON_META_DATA:
                response = 'Metadata event: framerate:  ' + eventObj.metaDataObj.framerate + ' fps.';
                break;
           }
    
        trace(response);
    }


    ActionScript3

    Example 1:

    import com.adform.events.AdformEventDispatcher;
    import com.adform.events.AdformVideoEvent;
    
    //event listener
    AdformEventDispatcher.addAdformEventListener(AdformVideoEvent.PLAY, eventHandler);
    function eventHandler(eObj:AdformVideoEvent):void
    {
    // custom code
    }
    
    //event dispatch
    btn.addEventListener(MouseEvent.CLICK, playButtonClick);
    function playButtonClick(e:MouseEvent):void{
        AdformEventDispatcher.dispatchAdformEvent(new AdformVideoEvent(AdformVideoEvent.PLAY,["adformVideoPlayer"]));
    }

    Example 2:

    import com.adform.events.AdformEventDispatcher;
    import com.adform.events.AdformVideoEvent;
    
    AdformEventDispatcher.addAdformEventListener(AdformVideoEvent.PLAY, callback);
    AdformEventDispatcher.addAdformEventListener(AdformVideoEvent.ON_META_DATA, callback);
    
    function callback(event:AdformVideoEvent):void {
        var response:String = '';
    
        switch (event.type) {
            case AdformVideoEvent.PLAY:
                response = 'Playing Video';
                break;
    
            case AdformVideoEvent.ON_META_DATA:
                response = 'Metadata event: framerate:  ' + event.metaDataObj.framerate + ' fps.';
                break;
        }
    
        trace(response);
    }

     

  • Video Event Object

    AdformVideoEvent object is passed with every video event and depending of its type may have the following properties.

    Property Type Description
    type String The name (type) of the event.
    targetArr Array An Array of instance names video controls affect.
    playProgress Number Video play progress (a fraction between 0 and 1).
    loadProgress Number Video load progress (a fraction between 0 and 1).
    duration Number Video playback duration.
    cuePointObj Object Video cue point event object.
    position Number Current video possition.
    metaDataObj Object Video meta data event object.
    netConnectionObj Object Video net connection event object.
    videoSource String Path to video source.
    volume Number Video sound volume from 0 to 1.
  • {event}.cuePointObj Object

    Event property cuePointObj has the following properties.

    Property Type Description
    name String The name given to the cue point when it was embedded in the video file.
    parameters Object A associative array of name/value pair strings specified for this cue point. Any valid string can be used for the parameter name or value.
    time Number The time in seconds at which the cue point occurred in the video file during playback.
    type String The type of cue point that was reached, either navigation or event.

  • {event}.netConnectionObj Object

    Event property netConnectionObj has the following properties.

    Property Type Description
    target Object Current video net connection object with all its properties.
    code String Code of current net connection status.
    description String Description of current net connection.
    data String Data of current net connection.
    level String Level of current net connection.
    objectEncoding String The object encoding for this NetConnection instance.

  • Video Componets Inspector Properties

    Video player and its controls basic properties can be defined using component inspector in Flash IDE. However these values will be always overwritten by flash vars.

    Video Controls (adformVideoPlayButton, adformVideoSeekBar, etc.)

    Property Description
    Video Players List An Array of video players instance names these video controls affects. User can specify several video components that listen to the current share button.

    Video Controls (adformVideoPlayButton, adformVideoSeekBar, etc.)

    Property Description
    Asset ID Id of a video asset, this player has to play from settings.xml.
    Auto Play true or false, defines if video should start play after completing its initialization.
    Enable Events true or false, defines if ”Adform” tracking events should be called.
    Is Streaming true – video source is streaming.
    false – video source is progressive.
    Loop Video true or false, defines if video playback should start playing again after it is completed.
    Sound On true or false, defines video sound is on or off on start.
    Video Source A path or URL string to video source.
    NOTE: This property will be ignored when “Asset ID” is defined.
    Poster ID Id of an image asset from settings.xml (*.jpg, *.jpeg, *.png, non-animated *.gif), this player has to show on video complete.
    Click-through Enabled true or false, allows components under the video component to receive click event. Supported in AS3 player only.
  • settings.xml

    „settings.xml“ is a file that contains data with all the video assets belonging to a current banner. Video component will try loading „settings.xml“ file when „Asset ID“ is defined and ,also, it will try to play the video asset depending of an indicated „Asset ID“ (see example).
     
    Example:

    <root>
      <assets>
        <asset id="1" bitrate="530"  bwsource="0" source="rtmp://yourserver.com/cbr/video-530.flv" />
        <asset id="2" bitrate="498"  bwsource="1" source="rtmp://yourserver.com/cbr/video-498.flv" />
        <asset id="3" bitrate="372"  bwsource="1" source="rtmp://yourserver.com/cbr/video-372.flv" />
        <asset id="4" bitrate="718"  bwsource="1" source="rtmp://yourserver.com/cbr/video-718.flv" />
        <asset id="5" bitrate="950"  bwsource="0" source="rtmp://yourserver.com/cbr/video-950.flv" />
        <asset id="6" bitrate="1255" bwsource="5" source="rtmp://yourserver.com/cbr/video-1255.flv" />
        <asset id="7" bitrate="0" bwsource="0" source="http://www.yourserver.com/other_video.flv" />
      </assets>
    </root>

     

    Weight
    ActionScript2:  adformVideoPlayer – 17095 bytes;
    ActionScript3: adformVideoPlayer – 19076 bytes;