Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1.  Initialize the Player.

    Code Block
    var player = new Frequency.Player();

    The player can be initialized with video and listener bindings so that it is one-shot ready to play or the player object can be constructed and setting the video to play and event listeners in subsequent method calls.   

    Code Block
    var player = new Frequency.Player(
                    undefined, {
                       video: {
                          url: 'clips.vorwaerts-gmbh.de/big_buck_bunny.mp4',
                          startPosition: 50,
                          autoplay: true,
                          adsConfig: {
                              adTagUrl: '/some/url/to/vast.xml',
                              adCuePoints: [12345, 23456, 34567]
                          }
                       },
                       events: {
                          onStateChange: function(state) {
                          },
                          onProgress: function(currentTime) {
                          }, (...)
                       } 
                    }      
                 );
    
    
  2. Add player event listeners.

    Code Block
    player.addEventListener(Frequency.Player.Events.onError, errorHandler);
    player.addEventListener(Frequency.Player.Events.onProgress, progressHandler);
  3. Play the video.

    Code Block
    player.loadVideo('http://videoURL.mp4);
    player.play();

    Here is a demonstration of the video playback and event handling in a typical HTML5 playback scenario:

    Frequency Player Demo

...

Code Block
loadVideo(url:String [, options])

Loads the video url specified by the url string. This does not auto play the video. The onMediaReady event would need to be monitored along with a subsequent video play() method call to cause the loaded video to play.

...

url - The url of the video to load.

options - additional options (optional) eg. adsConfig (Frequency.Player.AdsConfig)

Returns:

void

addEventListener

...

The Player Video class is a video data structure used for video player initialization along with video playback.

Fields 

Param

TypeDescriptionDefault
urlStringThe video file url.-
startPostionNumberThe video start position0
autoplayBooleanAutoplay the video after it is loaded.

false

 

hlsBooleanEnables MP4 HLS playerfalse
adConfigObjectFrequency.Player.AdsConfig object 

 

Player Ads Configuration

Code Block
Frequency.Player.AdsConfig

Fields

Param

Type

Description

adTagUrl

String

VAST document URL

adCuePoints

Array[Number]

array of cue points

Player Events Class

Code Block
Frequency.Player.Events

The Player Events class defines all the events that listeners can register on.

Event

Type

Description

onError

Function

An error occured.

onReady

Function

JS player ready for actions.

onMediaReady

Function

Media player ready.

onStateChange

Function

Player state has changed.

onProgress

Function

Players progress changed.

Video Playback States

State

Value

Description

UNKNOWN

undefined

Player state is unknown, player setup process did not finished.

UNSTARTED

-1

Player media ready but pending play action.

ENDED

0

Player finished playback.

PLAYING

1

Player is currently playing a video.

PAUSED

2

Player paused.

BUFFERING

3

Player is buffering.

LOCKED

4

Player locked by internal action.