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 Agent. The client Id and secret would be provided while onboarding a customer onto Quickplay platform. The client app must implement and provide user authorization agent which delivers the UMS token required for authorization with platform services.
The endPoints would be provided to a customer while onboarding onto Quickplay platform.
' Create configuration
platformAuthConfig = FLPlatformCoreFactory().authorizerConfiguration(clientId, clientSecret, xClientId, endPoint)
' Sample User Auth Agent implementation
userAuthAgent = FLPlatformCoreFactory().FLUserAuthorizationAgent()
userAuthAgent._flatToken = flatToken
userAuthAgent.fetchUserAuthorizationToken = function(context, callback)
userAuthData = FLUserAuthorizationData(m._flatToken)
callback(context, userAuthData, invalid)
end function
' Create Platform Authorizer
platformAuthorizer = FLPlatformCoreFactory().platformAuthorizer(platformAuthConfig, userAuthAgent)
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.
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
.
platformClient = FLPlatformCoreFactory().platformClient()
' platformClient.deviceId is the unique identifier of roku device
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.
' Persist the PlatformClient's `deviceId` and `deviceName` with roku registry
' Use the same to create same PlatformClient every app session to maintain same PlatformClient across app sesions
platformClient = FLPlatformCoreFactory().platformClient(deviceId, deviceName)
Create Content Authorizer
The ContentAuthorization
library assists with authorizing an asset for playback. 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 for which authorization is seeked. Upon successful authorization, PlaybackAsset
is obtained, which could be used to play with our Player
.
device = FLPlatformCoreFactory().platformClient()
' Create Content Authorizer Configuration
contentAuthConfig = FLContentAuthorizerFactory().contentAuthorizerConfiguration(contentAuthEndPoint, deviceRegistrationEndPoint, licenseRenewEndpoint)
' Create Content Authorizer
contentAuthorizer = FLContentAuthorizerFactory().contentAuthorizer(contentAuthConfig, device, invalid, m.platformAuthorizer)
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.
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
The player library is designed with goals to facilitate playback by PlaybackAsset
returned from Authorization response and to ease effort on integrators.
A PlatformAsset
could be constructed with APIs from ContentAuthorizer providing the following:
- Content Id: Unique identifier of the content
- Media Format: HLS | DASH
- DRM: Widevine | Playready
- Catalog Type: movie | tvepisode | shortvideo | sportshow | sporthighlight | sportclip | sportevent | sportsliveevent | channel | event
- Content Type: VOD | Live
' create asset for VOD playback
ssaiEnabled = false
platformAsset = FLContentAuthorizerFactory().vodAsset(contentId, catalogType, FLMediaFormat().DASH, FLDrmTypes().WIDEVINE, ssaiEnabled)
The created asset must be authorized with the Quickplay platform to obtain a PlaybackAsset
.
' authorize asset
callContext = m ' set instance from where invocation is made as call context
authHeader = invalid ' if any headers to be sent with auth
contentAuthorizer.authorizePlayback(platformAsset, authHeader, callContext, sub(context as object, playbackAsset as object, error as object)
m = context
if error <> invalid
' Handle error
else
' Playback with playbackAsset
end if
end sub)
Start Playback
The playback asset that is obtained upon authorization can be used for playback with FLPlayer
node as is without any modifications.
flPlayer.setField(flPlayerFields.ASSET, playbackAsset)
' Set License Headers if any
' call play
flPlayer.callFunc(flPlayerFunctions.PLAY)