Skip to main content

Free Preview

Free Preview authorizes a limited playback allowance. Android apps opt in on the content authorization request, then pass the returned allowance to HeartbeatManager for tracking.

Modes​

ModeApplicable contentConsumption tracking
FULLLive and VODServer-backed. Heartbeats report consumed preview time; the server decides extensions.
LIGHTSupported for LIVE onlyConsumption is persisted locally. The app decides whether to grant more time, for example after calling its backend.

Request authorization​

Set freePreview and fpMode on the PlatformAsset sent to authorizePlayback. FULL supports Live and VOD; LIGHT is supported for LIVE only.

val previewAsset = PlatformAsset(
mediaID = contentID,
mediaType = MediaType.DASH,
consumptionType = ConsumptionType.LIVE, // Use VOD for on-demand content.
catalogType = catalogType,
freePreview = true,
fpMode = FreePreviewMode.FULL
)

val result = contentAuthorizer.authorizePlayback(previewAsset, null)

When authorization succeeds, ContentAuthorizationToken.freePreview contains the allowance, or null when no preview was authorized.

PropertyMeaning
fpModeFULL or LIGHT
totalDurationTotal allowance, in seconds
consumedDurationPreviously consumed time, in seconds
remainingDurationAvailable time, in seconds
groupIdOptional identifier for sharing an allowance across related content
{
"freePreview": {
"fpMode": "full",
"totalDuration": 300.0,
"consumedDuration": 0.0,
"remainingDuration": 300.0,
"groupId": "optional-group"
}
}

Configure heartbeat tracking​

Pass the authorization response, main content's playback type, and Android Context to HeartbeatFactory.createHeartbeatManager.

val heartbeatManager = HeartbeatFactory.createHeartbeatManager(
contentId = token.contentID,
deviceId = deviceId,
heartbeatToken = token.heartbeatToken,
heartbeatConfiguration = heartbeatConfiguration,
platformAuthorizer = platformAuthorizer,
player = player,
freePreview = token.freePreview,
contentPlaybackType = when (previewAsset.consumptionType) {
ConsumptionType.LIVE -> ContentPlaybackType.LIVE
ConsumptionType.VOD -> ContentPlaybackType.VOD
},
context = context.applicationContext
)

For consumption tracking, pass all three values: freePreview, contentPlaybackType, and context. contentPlaybackType must describe the main asset, not an ad or slate. Omitting either contentPlaybackType or a usable context prevents reliable Light-mode consumption tracking and persistence.

Preview configuration​

Set these properties on HeartbeatConfiguration. The existing heartbeat interval remains independent of preview-extension checks.

PropertyDefaultBehavior
freePreviewExtensionCheckSec60.0 secondsRemaining time that triggers an extension check.
jitterSec60.0 secondsMaximum random extra time for the initial Light allowance, in 10-second increments. 0.0 disables jitter.
onFreePreviewExtensionnullLight-mode callback. The app may call its backend, then return additional seconds or 0.0 to decline. If unset, Light extensions are declined. Full mode checks with the server.
onFreePreviewProgressnullCallback for the initial allowance and each change in displayed whole seconds remaining.
val heartbeatConfiguration = HeartbeatConfiguration(
heartbeatEndPointURL = heartbeatEndPointURL,
freePreviewExtensionCheckSec = 60.0,
jitterSec = 60.0,
onFreePreviewExtension = { preview ->
// Light only: return extra seconds, or 0.0 to decline.
0.0
},
onFreePreviewProgress = { preview ->
// Update the UI with preview.remainingDuration.
}
)

Handle timeline events​

Listen through Player.Listener.onEventReceived and take the app-appropriate action:

val listener = object : Player.Listener {
override fun onEventReceived(
streamTimelineEvent: StreamTimelineEvent,
suggestedAction: Action,
streamTimelineMetadata: StreamTimelineMetadata?
) {
when (streamTimelineEvent) {
StreamTimelineEvent.FREE_PREVIEW_WILL_END -> {
val preview = (streamTimelineMetadata as? FreePreviewWillEndMetadata)?.preview
// Show a warning using preview?.remainingDuration.
}
StreamTimelineEvent.FREE_PREVIEW_ENDED -> {
val reason = (streamTimelineMetadata as? FreePreviewEndedMetadata)?.reason
// Show sign-in/subscription UI; the SDK stops playback.
}
else -> Unit
}
}
}
player.addListener(listener)

Flow summary​

  1. Request authorization with freePreview = true and the selected fpMode.
  2. Pass token.freePreview, the main content's contentPlaybackType, and a stable context to HeartbeatManager.
  3. Configure callbacks in HeartbeatConfiguration and handle timeline events in Player.Listener.
  4. Listen to timeline events and take the app-appropriate UI action, such as warning the user or showing subscription UI.

Heartbeat behavior and event timing​

The configured heartbeat interval (default 60,000 ms) controls regular heartbeat requests.

  • Full: Heartbeats include fpMode=full and fpConsumedDuration; at the extension threshold, the SDK calls the server.
  • Light: Heartbeats include fpMode=light; consumed time stays local, and the SDK invokes onFreePreviewExtension at the threshold.
  • FREE_PREVIEW_WILL_END: Warns that preview playback is going to end.
  • FREE_PREVIEW_ENDED: Reports ALLOWANCE_EXHAUSTED, UNSUPPORTED_CONTENT, or SERVER_STOP.