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: {
            onProgressonVolumeChange: (volume) => {
				console.log('Player volume is: ', volume)
            }
	});
onActivityFunctionActivity call succeeded.
Code Block
languagejs
new Frequency.Player(
    '#player', {
        session: {...},
        video: {..},
        events: {
            onActivity: (activity) => {
				console.log('Activity: ', activity, ' was send');
            }
	});
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;
				}
            }
	});

...