Skip to main content
Version: iOS 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:

PlaybackPolicy.publicPlaybackThe 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.signedPlaybackThe 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:

let params = UploadParams()
params.title = "My Video"
params.playbackPolicy = .signedPlayback // defaults to publicPlayback

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

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

Accessing a signed asset

To play the content of an asset which is marked as signedPlayback, 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.

let tokens: TokenRegistry = VideoKit.tokens()

// Add token by JWT string
let jwt: String = ...
tokens.addToken(jwt: jwt)

// Add token by constructing a token object
let token: Token = Token(id: tid, token: videoId, expiresAt: expirationDate, type: .video)
let token: Token = Token(id: tid, token: streamId, expiresAt: expirationDate, type: .stream)

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.