Creating an instance of AMP
To create an instance of AMP, use the function {@link akamai.amp.AMP.create}. You must pass the function to an HTML DOM element or a valid CSS selector to a DOM element:
var amp = akamai.amp.AMP.create("#amp");
Optionally you can pass a configuration object to function to set the player’s default settings:
var config = {
media: {
src: "http://projects.mediadev.edgesuite.net/customers/akamai/video/VfE.mp4",
type: "video/mp4",
autoplay: true
}
};
var amp = akamai.amp.AMP.create("amp", config);
Sometimes it is necessary to run additional code to set up the player. To ensure this code is run after the player is fully initialized, pass a function as the third argument:
var config = {
media: {
src: "http://projects.mediadev.edgesuite.net/customers/akamai/video/VfE.mp4",
type: "video/mp4",
autoplay: true
}
};
var amp = akamai.amp.AMP.create("amp", config, function (event) {
console.log(event);
});