DRM

AMP supports DRM content from the following providers:

  • Widevine
  • PlayReady
  • FairPlay

To enabled DRM content in the player, provide the keys property of the media object:

var config = {
	media : {
		source:[{
			src : "https://willzhanmswest.streaming.mediaservices.windows.net/609f4f57-1e5b-4898-90b1-81c574b2e8e3/VfE.ism/manifest(format=mpd-time-csf)",
			type : "application/dash+xml",
		}, {
			src : "https://willzhanmswest.streaming.mediaservices.windows.net/609f4f57-1e5b-4898-90b1-81c574b2e8e3/VfE.ism/manifest(format=m3u8-aapl)",
			type : "application/x-mpegURL",
		}],
		keys: {
			"com.widevine.alpha": {
				"serverURL": "https://willzhanmswest.keydelivery.mediaservices.windows.net/Widevine/?kid=4c241420-4ec4-42cb-9551-e9eb988d2911"
			},
			"com.microsoft.playready": {
				"serverURL": "https://willzhanmswest.keydelivery.mediaservices.windows.net/PlayReady/"
			},
			"com.apple.fps.1_0": {
				"serverURL": "https://willzhanmswest.keydelivery.mediaservices.windows.net/FairPlay/?kid=58ba906b-c94d-4d26-9403-905b6d6760d1",
				"cert": "FPSAC.cer"
			}
		}
	}
}

Some license requests require customer headers or credentials. These can be provided by passing a request object via the indivdual keys properties:

var config = {
	media : {
		source:[{
			src : "https://willzhanmswest.streaming.mediaservices.windows.net/609f4f57-1e5b-4898-90b1-81c574b2e8e3/VfE.ism/manifest(format=mpd-time-csf)",
			type : "application/dash+xml",
		}, {
			src : "https://willzhanmswest.streaming.mediaservices.windows.net/609f4f57-1e5b-4898-90b1-81c574b2e8e3/VfE.ism/manifest(format=m3u8-aapl)",
			type : "application/x-mpegURL",
		}],
		keys: {
			"com.widevine.alpha": {
				"serverURL": "https://willzhanmswest.keydelivery.mediaservices.windows.net/Widevine/?kid=4c241420-4ec4-42cb-9551-e9eb988d2911",
				"withCredentials": true
			},
			"com.microsoft.playready": {
				"serverURL": "https://willzhanmswest.keydelivery.mediaservices.windows.net/PlayReady/",
				"httpRequestHeaders": {
					"http-header-CustomData": "eyJ1c2VySWQiOiIxMjM0NSIsInNlc3Npb25JZCI6ImV3b2dJQ0p3Y205bWFXeGxJaUE2SUhzS0lDQWdJQ0p3ZFhKamFHRnpaU0lnT2lCN0lIMEtJQ0I5TEFvZ0lDSnZkWFJ3ZFhSUWNtOTBaV04wYVc5dUlpQTZJSHNLSUNBZ0lDSmthV2RwZEdGc0lpQTZJR1poYkhObExBb2dJQ0FnSW1GdVlXeHZaM1ZsSWlBNklHWmhiSE5sTEFvZ0lDQWdJbVZ1Wm05eVkyVWlJRG9nWm1Gc2MyVUtJQ0I5TEFvZ0lDSnpkRzl5WlV4cFkyVnVjMlVpSURvZ1ptRnNjMlVLZlFvSyIsIm1lcmNoYW50IjoiY2FibGVsYWJzIn0K"
				}
			},
			"com.apple.fps.1_0": {
				"serverURL": "https://willzhanmswest.keydelivery.mediaservices.windows.net/FairPlay/?kid=58ba906b-c94d-4d26-9403-905b6d6760d1",
				"cert": "FPSAC.cer"
			}
		}
	}
}

There are some advanced use cases for FairPlay that require special handling of the license request. Custom FairPlay handlers can be provided by passing in the fps config object. For example, to use an octet stream instead of the default form encoded message payload, the config might look something like:

var config = {
	media: {
		src : "https://willzhanmswest.streaming.mediaservices.windows.net/609f4f57-1e5b-4898-90b1-81c574b2e8e3/VfE.ism/manifest(format=m3u8-aapl)",
		keys: {
			"com.apple.fps.1_0": {
				"serverURL":"https://willzhanmswest.keydelivery.mediaservices.windows.net/FairPlay/?kid=58ba906b-c94d-4d26-9403-905b6d6760d1",
				"cert": "FPSAC.cer"
			}
		}
	},
	fps: {
		requestLicense: function(message, contentId, serverUrl, keys) {
			var request = {
				url: serverUrl,
				method: "POST",
				responseType: "arraybuffer",
				headers: {
					"Content-Type": "application/octet-stream",
					"utoken-drm": "fp"
				},
				data: new Uint8Array(message)
			};

			return akamai.amp.Utils.request(request).then(function (xhr) {
				return new Uint8Array(xhr.response);
			})
			.catch(function (error) {
				throw "The license request failed.";
			});
		}
	}
};

The full list of FairPlay overrides are:

var config = {
	fps: {
		extractServerUrl: function (initData, keys) {
			return // String. The server url
		},
		extractContentId: function (initData, keyData) {
			return // String. The content id
		},
		requestCertificate: function (keys) {
			return // Promise.<Uint8Array>
		},
		concatInitDataIdAndCertificate: function (initData, id, cert) {
			return // Uint8Array
		},
		requestLicense: function (message, contentId, serverUrl) {
			return // Promise.<Uint8Array>
		}
	}
}