Skip to main content

Secure Playback

Create Platform Authorizer

The PlatformCore or PlatformAuthorizer facilitates seamless interaction with all Quickplay platform services with industry standard security model. It is suggested to create one instance of platform authorizer and use it for one app session.

To create an instance of Platform Authorizer, one would require client Id, client secret, xClientId, authorization endPoint and User Authorization Delegate. The client Id and secret would be provided while onboarding a customer onto Quickplay platform. The client app must implement and provide user authorization delegate which delivers the UMS token required for authorization with platform services.

The endPoints would be provided to a customer while onboarding onto Quickplay platform.

// Platform Authorizer creation snippet
const platformConfig = {
clientID: clientId,
clientSecret: clientSecret,
xClientId: xClientId,
authorizationEndPoint: endPoint,
};

// Implement UserAuthorizationDelegate and use it to create PlatformAuthorizer
const platformAuthorizer = flPlatformAuthorizer.createPlatformAuthorizer(
platformConfig,
{
fetchUserAuthorizationToken: () => {
return { accessToken: accessToken };
},
},
);
note

At any point of time only one instance of PlatformAuthorizer could be created and it is suggested to use this instance for the complete application session. The existing PlatformAuthorizer instance must be disposed by calling platformAuthorizer.dispose() before creating a new one.

danger

The application owns the responsibility of returning valid user token through the userAuthorizationDelegate implementation. Whenever there is a change in user using the application, the user token must be refreshed accordingly.

Create Platform Client

The content authorizer is married to one particular device, Quickplay client library provides an API to generate a unique PlatformClient instance which gives access to a unique device id.

interface PlatformClient {
/**
* Unique identifier of the client or device.
*/
id: string;

/**
* Name of the client or device.
*/
name: string;
}

A unique instance of PlatformClient can be generated as shown below. Applications are required to persist the generated platform client instance to identify the same device on subsequent sessions.

let platformClient;

if (hasCachedPlatformClient) {
const platformClient = flPlatformAuthorizer.createPlaformClient(
cachedDeviceId,
cachedDeviceName,
);
savePlatformClient(platformClient);
} else {
platformClient = flPlatformAuthorizer.createPlaformClient();
}

Create Content Authorizer

The fl-content-authorization library assists with authorizing an asset for either playback or download. To create an instance of content authorizer one would need platform authorizer, device registration endPoint, content authorization endPoint and a client device.

The content authorizer expects PlatformAsset which represents a potential playable asset and delivery type for which authorization is required. The delivery type is streaming upon successful authorization, PlatformAsset is obtained, which could be used to play with our Player.

// Content Authorizer creation
const contentAuthconfiguration = {
endPointUrl: contentAuthEndPoint
clientRegistrationEndPointUrl: deviceRegistrationEndPoint,
};

const contentAuthorizer = flContentAuthorization.createContentAuthorizer(
contentAuthconfiguration,
platformAuthorizer,
platformClient);

note

It is suggested to create contentAuthorizer during start of application and invoke contentAuthorizer.registerDevice ensuring device registration prior to content authorization. If not done, contentAuthorizer would automatically register device prior to the very first content authorization request. Performing device registration at app launch would optimise authorization response time during the first authorization request. There is no limit on contentAuthorizer instance creation, however, it is suggested to use one instance for the complete application session.

danger

A contenAuthorizer is tied to a single device(PlatformClient) and user during its life time. Whenever there is a change with user using the application or change in deviceId(when deviceId was provided while constructing PlatformClient), it is mandatory to re-register the device.

Authorize Playback for an Asset

The player library is designed with goals to facilitate playback by content url and to provide utmost control for integrators.

A PlatformAsset could be constructed with APIs from ContentAuthorizer providing the following:

  • Content Id: Unique identifier of the content
  • Media Format: HLS | DASH | SmoothStream
  • DRM: Fairplay | Widevine | Playready
  • Catalog Type: movie | tvepisode | shortvideo | sportshow | sporthighlight | sportclip | sportevent | sportsliveevent | channel | event
  • Content Type: VOD | Live
// create asset
const asset = contentAuthorizer.authorizePlayback({
mediaID: platformcontentId.value,
consumptionType: flContentAuthorization.ConsumptionType.VOD,
catalogType: 'movie',
mediaType: flPlayerInterface.MediaType.DASH,
drmScheme: flPlayerInterface.DrmScheme.WIDEVINE,
});

Start Playback

A Player instance could be created by supplying player builder properties like contentURL, mediaType, drmScheme, etc to PlayerBuilder class.

// Creating Player
const playerBuilder = flPlayer.createPlayerBuilder();

const playbackOptions = {
PlayOnLoad: true,
preferredAudioLanguage: 'fr',
preferredTextLanguage: 'fr',
networkRetries: 3,
networkTimeout: 40,
initialPlaybackTime: 0,
minBuffer: 30,
maxBuffer: 30,
bufferBehind: 40,
};

const player = playerBuilder
.mediaElement(videoElement)
.mediaUrl(asset.contentUrl)
.drmLicenseUrl(asset.licenseUrl)
.drmScheme(asset.drmScheme)
.playbackOptions(playbackOptions)
.build();

player.play();