Techdocs

AMP Web SDK

AMP player

Settings defaults

This tutorial shows how to set up the default value for the available user settings on AMP.

Setting Defaults

As explained in Embedding AMP, AMP is configured by passing a configuration object that matches the akamai.amp.PlayerConfig. As it can be seen in the akamai.amp.PlayerConfig interface page it includes the member settings. The member settings is an instance of akamai.amp.Settings. It is used by AMP to track and set up the player user settings. In order to set up defaults, the Settings class includes the static attribute defaults that can be used to set a default volume and captions object.

Currently AMP supports defaults for the following:

  1. Volume
  2. Closed Captions

1. Volume

By setting the attribute volume to a value between 0 and 1 you can set the default volume used by the player when loaded.

var config = {
	settings: {
		defaults: {
			volume: 0.5
		}
	}
};

2. Closed Captions

By setting the attribute captions to an object matching the akamai.amp.CaptionSettings interface you can set the default way the closed caption will be displayed by the player.

var config = {
	settings: {
		defaults: {
			captions: {
				visible: true,
				fontFamily: "monospacedSerif",
				fontSize: "large",
				fontColor: "white",
				fontOpacity: "100%",
				edgeType: "rightShadow",
				edgeColor: "black",
				edgeOpacity: "50%"
				backgroundColor: "black",
				backgroundOpacity: "50%",
				windowColor: "black",
				windowOpacity: "50%",
				scroll: "popout"
			}
		}
	}
};