Spoiler Prevention

Sync social content with live video playback to prevent spoilers in the StreamLayer Android SDK. Implement SLRTimeCodeProvider to keep the Highlights unit aligned with the user's stream position.

Spoiler Prevention

The StreamLayer SDK includes built-in spoiler prevention. When enabled, social content in the Highlights unit is synced with the live video, so users never see results or updates ahead of their current playback position.

Note: Video On Demand (VOD) is not currently supported with this feature.

To enable spoiler prevention, provide a value that represents the date/time of your media player's current playback position.

ExoPlayer Streams

If you use ExoPlayer for your streams, your stream must support the EXT-X-PROGRAM-DATE-TIME tag. If you use a different player or need to calculate the reference time using a different strategy, return your custom epoch time to keep the Highlights unit synced with your stream.

Enabling the Feature

To use spoiler prevention, provide an SLRTimeCodeProvider when calling StreamLayer.createEventSession(). If your stream does not support EXT-X-PROGRAM-DATE-TIME, pass null for timecodeProvider.

val session = StreamLayer.createEventSession(eventId, timecodeProvider)

SLRTimeCodeProvider Signature

interface SLRTimeCodeProvider {
 fun getEpochTimeCodeInMillis(): Long
}

Example Implementation

object : SLRTimeCodeProvider {
    override fun getEpochTimeCodeInMillis(): Long {
        val timeline = exoPlayer.currentTimeline
        return if (!timeline.isEmpty) timeline.getWindow(
                    exoPlayer.currentWindowIndex, Timeline.Window()
                ).windowStartTimeMs + exoPlayer.currentPosition
                else exoPlayer.currentPosition

For a complete usage example, see the demo app.


Related