Skip to main content
Version: Android 1.2.1

Signed Playback

VideoKit SDKs let you play different kinds of assets (videos, live streams) and protect the playback using signature Tokens. To understand how it works, you should first of all familiarize with the PlaybackPolicy enum:

|Value|Description| |PlaybackPolicy.PUBLIC|The given asset can be accessed by url publicly without any kind of signature. Anyone who knows the url will be able to play the asset.| |PlaybackPolicy.SIGNED|The asset playback is protected by a signature. The content can only be accessed by adding a token query parameter to the url.|

Specifying the asset policy#

The playback policy is defined at the time of creating the asset. In the case of videos, this means that it is specified in the video UploadRequest:

val request = {
title("My Video")
playbackPolicy(PlaybackPolicy.SIGNED) // defaults to PUBLIC

After creation, it can also be retrieved at any time using Video.playbackPolicy.

val video: Video = ...
if (video.playbackPolicy == PlaybackPolicy.PUBLIC) {
// Video URLs are public

Accessing a signed asset#

To play the content of an asset which is marked as SIGNED, a signature token must be passed to the SDK's TokenRegistry. Tokens are JWT strings that contain all the information needed to determine whether the content can be accessed or not.

val tokens: TokenRegistry = VideoKit.tokens()
// Add token by JWT string
val jwt: String = ...
// Add token by constructing a token object
val token: Token = Token(jwt, videoId, TokenType.VIDEO, expirationDate)
val token: Token = Token(jwt, streamId, TokenType.STREAM, expirationDate)

The SDK components will automatically access the token at playback time and modify the url accordingly when needed.

Generating a signature token#

For instructions on how to generate the tokens, please refer to the Signed Playback tab in your app settings in the dashboard.

Last updated on