akamai.amp.AMP

AMP

new AMP()

Methods

create

(static) create(container, configopt, onreadyopt) → {Promise.<akamai.amp.Player>}

Create a player based on the configuration object and container.

Parameters
Name Type Attributes Description
container string | HTMLElement

The id of the div the player will be attached to.

config akamai.amp.PlayerConfig | string <optional>

The configuration override object, or JSON string. Must adhear to the akamai.amp.PlayerConfig interface.

onready function <optional>

Optional ready handler.

Tutorials:
  • Tutorial: 2-amp-create
Returns
Promise.<akamai.amp.Player>

defaults

(static) defaults(overrides) → {Object}

Overrides the Config defaults.

Parameters
Name Type Description
overrides Object

The overrides.

Returns
Object

The new defaults object

evaluateBindings

(static) evaluateBindings(value, context) → {Object|string}

Evaluate a data bound object.

Parameters
Name Type Description
value Object | string

The data bound object.

context Object

The context object used as "global" when evaluating the binding.

Returns
Object | string

The evaluated result

getVersion

(static) getVersion() → {string}

Returns the version string for this player library.

Returns
string

The version string.

loadResources

(static) loadResources(resources, callback) → {Promise}

Loads a list of JS and CSS resources.

Parameters
Name Type Description
resources Array.<akamai.amp.Resource>

The list of js and css resources

callback function
Returns
Promise

Promise which resolves once all resources have been loaded.

registerPlugin

(static) registerPlugin(key, mode, factory)

Registers a plugin factory function. This function is called when {{manifest.qualifiedName}}.create is called and the config object contains the plugin key.

Parameters
Name Type Description
key String

The plugin key. Used to configure the plugin.

mode String | Array.<String>

The player mode(s) in which the plugin can be used.

factory function
Tutorials:
  • Tutorial: 9-custom-plugin
Example
akamai.amp.AMP.registerPlugin("sample", ["html", "flash"], function (player, config, key) {
  return new Promise(function (resolve, reject) {
    resolve({
      config: config,
      testing: function () { console.log("Sample Plugin Public API Function: " + this.config.testing); }
    });
  });
});

akamai.amp.AMP.create("akamai-media-player", {sample: {testing: 1235}}, function () {
  amp.sample.testing();
});

request

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

Request a http resource.

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

A url object or string.

Returns
Promise.<XHR>

Promise which resolves to a XHR object

requestJson

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

Request a http json resource.

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

A url string or an object containing the following properties:

Returns
Promise.<Object>

Promise which resolves to a js object

require

(static) require(id) → {Promise.<akamai.amp.PlayerResource>}

Loads resource from url or cache

Parameters
Name Type Description
id string

A url or id of the resource

Returns
Promise.<akamai.amp.PlayerResource>

Promise which resolves to an object