Loading Media
Media can be supplied to the player in one of two ways:
-
Set the media property of the AMP instance.
amp.media = { src: "http://projects.mediadev.edgesuite.net/customers/akamai/video/VfE.mp4", type: "video/mp4" };;
-
Add a media property to the player’s configuration object.
var config = { media: { src: "http://projects.mediadev.edgesuite.net/customers/akamai/video/VfE.mp4", type: "video/mp4", autoplay: true, startTime: 0 } }; akamai.amp.AMP.create("amp", config).then(player => { var amp = player });
In both cases, the object must adhere to the media interface.
For the best playback experience on all devices and platforms, it is suggested that multiple stream formats be provided per media item.
This can be done by using the source
property instead of the src
and type
properties:
var config = {
media: {
title: "VOD Sample",
poster: '../resources/images/hd_world.jpg',
source: [{
src: "https://mdtp-a.akamaihd.net/customers/akamai/video/VfE.mp4",
type: "video/mp4"
}, {
src: "https://mdtp-a.akamaihd.net/vod/hls/BLENDER-BUNNY/master.m3u8",
type: "application/x-mpegURL"
}]
}
};
akamai.amp.AMP.create("amp", config).then(player => {
var amp = player
});