Summary

Frequency's Javascript video player is built as an end all solution for short form video to support a myriad of third party players, media formats, advertising requirements, financial settlements, and reporting. This document describes the technical capabilities of the player. 

Player can be loaded as html from https://static.frequency.com/player/<version>/index.html or as standalone js file http://static.frequency.com/player/<version>/_assets/interface.js

PlayerLite can be downloaded as javaScript file from https://static.frequency.com/player/<version>/_assets/playerLite.js

Conviva builds can be found using <version>_conviva

Version History

Version #DescriptionRelease Date
3.0.5

Changes

  • Added a work around for fetch commands when a browser does support it natively
  • Enhanced error management to ignore undefined errors so they are not returned in the OnError event

 

October 27, 2017
3.0.2

Changes

  • Remove testrunner

 

October 23, 2017
3.0.0

Changes:

  • New method for loading channels feed
  • New method for loading video

Breaking changes:

  • loadVideo method and video object constructor expecting video_id string instead of object
September 5, 2017
2.2.0

Changes:

  • deprecated loadVideo method
  • additional controls elements
  • removed Dailymotion and Vimeo players

Bugfixes:

  • autoplay issue on ios
  • events memory leaks
September 1, 2017
2.1.2

Changes

  • Ad fixes
August 19, 2017
2.1.1

Changes

  • Ad fixes
July 19, 2017
2.1.0

Changes

  • support for VAST error trackers
  • support for DNT
  • support for forcing ad delivery protocol
  • maximum and minimum Ad resolution support
  • maximum and minimum bitrate Ad support
  • additional player controls UI
  • New events
    • onActivity
    • onAd

Bugfixes:

  • State PLAYING not received after SEEKING
  • Edge Incorrect handling for SEEKING status for some videos.
  • Video doesn't pause at starting playback
  • Watch10 request is sent after forwarding the video
  • Player doesn't playback picked video after advertising ends.
  • Memory leaks for advertisements
July 11, 2017
2.0.4

Bugfixes:

  • API url is not supported in constructor call
March 23, 2017
2.0.3

Bugfixes:

  • "autoplay" is ignored
  • playerLite memory leaks
  • VAST impression support
March 16, 2017
2.0.2

Bugfixes:

  • Player does not emit onVolumeChange event during playing ads 
  • Current time is not equal to Duration on video End 
  • Video doesn't pause at starting playback
  • Infinite SEEKING state after advertisement 
  • "autoplay" is ignored

Breaking changes:

  •  please provide source instead of source_id in video object for ads 
February 22, 2017


Browsers & Device Support

Frequency's player is supported on the following browsers and devices. 


Desktop BrowserVersionMp4HLSYouTubeVimeoDailyMotion
IE10+YesNoYesYesNo
Edge13+YesYesYesYesYes
FF30+Yes41+YesYesYes
Chrome35+YesYesYesYesYes
Opera30+YesYesYesYesYes
Safari6.2+YesYesFlashYesFlash
Mobile OSVersionMp4HLSYouTubeVimeoDailyMotion
Android4.4+YesYesYesYesNo
iOS6.0+YesYesYesYesNo
Windows Phone8.1+YesNoYesYesYes

Players & Formats

The Frequency Javascript video player provides a Javascript class and a set of constructs that makes short form video playback with advertisement a simple task. The supported video formats are:

Player / FormatExample
Youtube

http://www.frequency.com/video/game-of-thrones-season-6-trailer-2-hbo/253199983?cid=4-8621

H264http://once.unicornmedia.com/now/stitched/mp4/8e6db0ba-80b7-4c02-b328-07d1af9ee5d3/7aab0ba9-921d-4d44-8ee9-938049fb3572/a07db314-1579-44ce-93cd-ee9c63cfc294/3eccdfc7-4e10-4f4e-b07f-17ab769ba565/content.mp4
HLShttp://once.unicornmedia.com/now/adaptive/m3u8/95286106-b310-4123-abd8-76e9b8fa5ccb/2d45f3f5-1836-46b2-9b48-125be611c8eb/be919c0f-034f-4008-b288-3e7ff1523002/content.m3u8?UMLITERAL%3Dfkey%2C14%26guid 

Fullscreen API support

 The Frequency Javascript video player provides wrapper around Fullscreen API. Supported browsers:

Desktop BrowserVersion
IE11+
Edge12+
FF10+
Chrome15+
Opera15+
Safari5.1+
Mobile OSVersion
Android-
iOS-
Windows PhoneIE Mobile 11+

Class Documentation

Player Class

The Player class plays videos from HTML5 web apps. The Player supports advertisement playback and beaconing along with standalone video playback transparently. 

Param
Type
Description
elementString or DOMNodeNode selector or DOMNode the player will be inserted into.
optionsObjectFrequency.Player.Options object 

Player Constructor

new Frequency.Player({
    config: {// optional
        basePath: '.'
    },
    session: {// mandatory
        'x-frequency-auth': '013ffaa2-a64e-4974-a9ee',
        'x-frequency-deviceid': '5680c4f2-e3fd'
    },
    adConfig: {// optional
        minBitrate: 100,// kbps
        maxBitrate: 5000,// kbps
        maxResolution: '720p',
        minResolution: '720p',
        deliveryFormat: 'progressive',// progressive / streaming
		deliveryProtocol: 'https',// http / https
		format: 'video/mp4'
    },
	controls: { // boolean or object [default: false]
    	player: { // boolean or object [default: true]
			// css: 'sample-link-to--player.css'
        },
		ads: { // boolean or object [default: true]
			// css: 'sample-link-to--adsplayer.css',
            strings: { // optional
	            VIDEO_WILL_START_SOON: 'Keep calm and watch the ad, video will start in [time_left]s...',
                SKIP_AD: 'Skip'
            }
        }
    },
    video: "1234567",//optional
    autoplay: true, //optional default false
    events: {// optional
    	onStateChange(state) {
			...
		}  
    }
})

           

Constructs a Player object for video playback.

Constructor also accept element, which will be replaced by video player (* PlayerLite can only accept existing video element)

// element provided as string
new Frequency.Player('#player', {...});
 
// element provided directly as DOM node
new Frequency.Player(document.getElementById('player'), {...});
new Frequency.PlayerLite(document.getElementsByTagName('video')[0], {...});


Parameters:

video - The Frequency.Player.Video object containing the video url, playback start position along with whether to auto play the video once loaded.

events - The Frequency.Player.Events object to bind playback event listeners.

session - User session tokens required for activities.

api - Api configuration for activities.

config - player configuration.

Returns:

An initialized Player object.


Player Methods

play

play()

Plays the currently loaded video.

Parameters:

None

Returns:

void


pause

pause()

Pauses the currently playing video.

Parameters:

None

Returns:

void


seekTo

seekTo(time:Number)

Seeks to a specified time in the video.

Parameters:

time - The time position (in seconds) in the video to jump to. 

Returns:

void

  

getDuration

getDuration()

Returns the duration of the currently playing video in seconds.

Parameters:

None

Returns:

Number - The video duration in seconds.


getState

getState()

Returns the video player's current play state.

Parameters:

None

Returns:

Number - The number representing the video playback state. (see video states).


getCurrentTime

getCurrentTime()

Returns the lapsed time since the video start in seconds.

Parameters:

None

Returns:

Number - The lapsed video playback time in seconds.


loadVideo

loadVideo(video_id[, autoplay:boolean])

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

Parameters:

video_id - string with video_id that will be played

Returns:

void

 

loadChannel

 

loadChannel(channel_id[, autoplay:boolean])

 

Loads video feed for specified channel_id. The onMediaReady event would need to be monitored along with a subsequent video play() method call to cause the loaded video to play.

 

Parameters:

 

channel_id - string with channel_id that will be played

 

Returns:

 

void

 

 

 

setVolume

setVolume(volume:Number)

Sets player volume.

 Parameters:

 volume - New volume value for player. Value must be in range 0-100 

Returns:

void 

getVolume

getVolume()

Returns current volume for the player.

Parameters:

 none

Returns:

 Number

 

isFullscreen 

isFullscreen()

Returns true if player is in fullscreen mode.

Parameters:

 none

Returns:

 Boolean

requestFullScreen

requestFullScreen()

Tries to put player in fullscreen mode.

Parameters:

 none

Returns:

 none


exitFullScreen

exitFullScreen()

Tries to disable fullscreen mode for player.

Parameters:

 none

Returns:

 none

setSession

setSession(session:Object)

Updates player session for activities.

Parameters:

session - Session object ({'X-Frequency-Auth': '...', 'X-Frequency-DeviceId': '...'})

Returns:

void

addEventListener

addEventListener(event:String, callback:String)

Adds a listener function for the specified event. 

Parameters:

event - The event to register for listening. (See Player events)

callback - The event handler method of code block.

Returns:

void 


removeEventListener

removeEventListener(event:String, callback:String)

Removes a listener function for the specified event.

Parameters:

event - The listening event. (See Player events)

callback - The event handler method or code block.

Returns:

void


Player Video Class

Frequency.Player.Options.Video

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


Player properties

version - current player version

Player Events Class

Frequency.Player.Events

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

Event

Type

Description

 

onError

Function

An error occurred.

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

onReady

Function

JS player ready for actions.

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.

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.

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.

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

Activity call failed.

 

 
onAdFunctionAd event occured
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.

 

Code Examples

iOS sample project of implementation of the frequency javascript player in a webview - frequency-ios-sdk-demo.zip.

Android sample project of implementation of the frequency javascript player in a webview - HelloFrequencyPlayer-android.zip.

Demo

Frequency Player Demo