akamai.amp.Utils

A collection of utility functions for the player

Constructor

Utils

new Utils()

Methods

clone

(static) clone(obj, deepCopyopt) → {Object}

Clones an object.

Parameters
Name Type Attributes Default Description
obj Object

The object to be cloned.

deepCopy boolean <optional>
true

Recursively clone the object.

Returns
Object

flattenTimecode

(static) flattenTimecode(timeCode, framerateopt) → {number}

Converts timecode to seconds.

Parameters
Name Type Attributes Default Description
timeCode string

A SMTP formatted string.

framerate number <optional>
30

The frame rate. Used to calculate milliseconds.

Returns
number

The number of seconds represented by the time code

formatTimecode

(static) formatTimecode(time, duration) → {string}

Takes a time in seconds and converts it to timecode.

Parameters
Name Type Description
time number

The time in seconds to be formatted.

duration number

The duration in seconds

Returns
string

A SMTP formatted string.

getPlaybackMode

(static) getPlaybackMode(dflt) → {akamai.amp.PlaybackMode}

Determine the playback mode for the player.

Parameters
Name Type Description
dflt akamai.amp.PlaybackMode

The default playback mode if one cannot be inferred

Returns
akamai.amp.PlaybackMode

The inferred playback mode

getViewability

(static) getViewability(element) → {string}

Determines the viewablility of an element

Parameters
Name Type Description
element string | HTMLElement

The DOM element or CSS selector

Returns
string

The viewability of "full", "partial", or "none"

isTouchDevice

(static) isTouchDevice() → {boolean}

Check if the platform is a touch device

Returns
boolean

isViewable

(static) isViewable(element) → {boolean}

Determines if an element is fully viewable

Parameters
Name Type Description
element string | HTMLElement

The DOM element or CSS selector

Returns
boolean

true if fully viewable

override

(static) override(base, overrides, cloneopt) → {Object}

Override the properties of a base object with the values of an override object.

Parameters
Name Type Attributes Default Description
base Object

The base object.

overrides Object

key/value overrides

clone boolean <optional>
true

Return a clone of the object instead of modifiying the original

Returns
Object

request

(static) request(url) → {Promise.<XHR>}

Make an HTTP(S) request

Parameters
Name Type Description
url akamai.amp.Request | string

The url to be requested.

Returns
Promise.<XHR>

requestJson

(static) requestJson(url) → {Promise.<Object>}

Make an HTTP(S) request for a json resource

Parameters
Name Type Description
url akamai.amp.Request | string

The url to be requested.

Returns
Promise.<Object>

requestText

(static) requestText(url) → {Promise.<string>}

Make an HTTP(S) request for a text resource

Parameters
Name Type Description
url akamai.amp.Request | string

The url to be requested.

Returns
Promise.<string>