Skip to main content
Version: Android SDK v1.3.0

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:

ValueDescription
PlaybackPolicy.PublicThe 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.SignedThe 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 UploadParams:

val request = UploadParams.build {
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 = ...
tokens.addToken(jwt)

// 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)
tokens.addToken(token)

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 video.io dashboard.