Page tree

Versions Compared

Key

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

...

Event

Type

Description

 

onError

Function

An error occurred.

 
Code Block

 

languagejs
new Frequency.Player(
    '#player', {
        session: {...},
        video: {..},
        events: {
            onError: (error) => {
				//Error occured
                console.log('onError', error)
            }
	});

onReady

Function

JS player ready for actions.

 
Code Block
languagejs
new Frequency.Player(
    '#player', {
        session: {...},
        video: {..},
        events: {
            onReady: () => {
				/* Player is ready to take actions
				*  Do not call player before this event
				*/
            }
	});

onMediaReady

Function

Media player ready.

 
Code Block
languagejs
new Frequency.Player(
    '#player', {
        session: {...},
        video: {..},
        events: {
            onMediaReady: () => {
				/* Player video is ready for playback
				*  if video had autoplay flag it will
				*  start playing after this event
				*/
            }
	});

onStateChange

Function

Player state has changed.

 
Code Block
languagejs
new Frequency.Player(
    '#player', {
        session: {...},
        video: {..},
        events: {
            onStateChanged: (state) => {
				/* Player state did changed
				*  state is one of the states mentioned above 
				*/
				console.log('New player state: ', state)
            }
	});

onProgress

Function

Players progress changed.

 
Code Block
languagejs
new Frequency.Player(
    '#player', {
        session: {...},
        video: {..},
        events: {
            onProgress: (currentPlaybackTime) => {
				console.log('Player playback time is: ', currentPlaybackTime)
            }
	});
onVastEventFunctionVast Ad Event occurred. 
onVolumeChangeFunctionPlayer volume has changed. 
Code Block
languagejs
new Frequency.Player(
    '#player', {
        session: {...},
        video: {..},
        events: {
            onProgress: (volume) => {
				console.log('Player volume is: ', volume)
            }
	});
onActivityFunctionActivity call succeeded. 
onActivityErrorFunction

Activity call failed.

 

 
onAdFunctionAd event occured 
Code Block
languagejs
new Frequency.Player(
    '#player', {
        session: {...},
        video: {..},
        events: {
            onAd: (adMessage) => {
				switch (adMessage.action) {
					case 'start':
						console.log('ad just started to play', adMessage.ad);
						/* adMessage.ad = {
						*	title: ...,
						*	duration: ...,
						*	skipOffset: ...
						*}
						*/
						break;
					case 'end':
						console.log('ad just ended to play');
						break;
					case 'timeupdate:
						console.log('current ad progress is:', adMessage.progress); 
						console.log('current ad duration is:', adMessage.duration);
						break;
				}
            }
	});

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.

 

SEEKING5Played seeking.
ERROR6Player interface returned error.

...