Spoiler Prevention

Sync StreamLayer ad and game units with timestamped video to provide a spoiler-free experience on iOS.

If your video stream includes timestamps, the StreamLayer SDK can sync ad and game units to the viewer's playback position. When Spoiler Prevention is enabled, all published content appears in chronological order relative to the live video — so viewers watching on a delay see units at the correct moment.

📘

Spoiler Prevention requires timestamped video. Video on Demand (VOD) is not currently supported.

To enable Spoiler Prevention, provide a value representing the date/time of your media player's current playback position.

AVPlayer Streams

If you use AVPlayer, your stream must include the EXT-X-PROGRAM-DATE-TIME HLS tag. The SDK reads the current program date from the player item to calculate the correct epoch time.

If you use a different player or need a custom timecode strategy, implement the SLRTimecodeProvider protocol and return your own epoch time.

Enable Spoiler Prevention

Pass a SLRTimecodeProvider when creating the session:

StreamLayer.createSession(for: eventId, timecodeProvider: self)

TimecodeProvider Protocol

public protocol SLRTimecodeProvider {
 func getEpochTimeCodeInMillis() -> TimeInterval
}

AVPlayer Implementation Example

extension ViewController: SLRTimecodeProvider {
 public func getEpochTimeCodeInMillis() -> TimeInterval {
    guard let date = player?.currentItem?.currentDate() else {
      return 0.0
    }
    return date.timeIntervalSince1970
 }
}

Related