Skip to main content

Live Playback

To play a live stream from Quickplay Platform, follow the steps described in Secure Playback, and update the platform asset to indicate you are trying to play a Live stream.

A PlatformAsset for playing a Live Stream could be constructed with APIs from ContentAuthorizer by providing the following:

  • Content Id: Unique identifier of the content
  • Media Format: HLS | DASH | SmoothStream
  • DRM: Fairplay | Widevine
  • Content Type: Live
  • Catalog Type: channel | event | sportsliveevent
  • Playback Mode: Live | Restart | Catchup
  • Start Time: Start time of the Live Program
    • Required for playback modes restart and catchup, optional otherwise
  • End Time: End time of the Live Program
    • Required for playback mode catchup, optional otherwise
// create asset
val platformAsset = PlatformAsset(
contentId,
MediaType.DASH,
consumptionType,
catalogType,
DrmType.WIDEVINE,
PlaybackMode.LIVE
)

Seeking in live streams

When playing a Live stream, the player always starts playing from the Live Edge. To seek anywhere within the live window, you can use the standard seek APIs, refer to Basic Playback. The seek position is always relative to the start of the live window. The player will try to maintain the same live offset after a seek.

To force the player to play from Live Edge of the current Live Window, use the seekToLiveEdge API. The currentOffsetFromLiveEdgeMs API can be used to determine if the player is currently playing at or beginning the Live Edge.

Player APIs for live playback positions:

Property NameTypeDescription
currentEpochTimeMsLongCurrent time expressed in epoch.
currentOffsetFromLiveEdgeMsLongThe time difference between current playback position and live edge position, in milliseconds.
currentTimeInWindowMsLongThe current playback position (in milliseconds) expressed within the limits of the current live window.
currentWindowDurationMsLongThe total duration of the current live window, in milliseconds.
Live Playback timeline
note

Live seeking is limited to the duration of the current live window (currentWindowDurationMs). If the playback is seeked to / paused and resumed / buffered to any playback position behind the live window, a 0x40020d error will be thrown.

Listening to end of live stream

When playing a live program or event, Quickplay platform authorizes the playback for the current program/event. Any subsequent program/event should be re-authorized.

During live playback, StreamTimelineEvent.LIVE_PROGRAM_END with Action.NONE can be observed by implementing the following in the attached Player.Listener.

override fun onEventReceived(
streamTimelineEvent: StreamTimelineEvent,
suggestedAction: Action,
streamTimelineEventMetadata: StreamTimelineEventMetadata?
) {
when(streamTimelineEvent) {
is StreamTimelineEvent.LIVE_PROGRAM_END -> {
//Handle end of live stream as required
}
}
}

Live Playback Modes

Live Playback can be classified into 3 modes: Live, Restart and Catchup modes. Though the level of control will change depending on the playback mode, playback controls like pause and scrub are supported in all modes.

Live mode

Live mode should be used when the playback is expected to be reasonably close to real time. The duration of buffer that should be available (i.e. the duration of playback behind real time that the player is expected to be able to play at all times) behind the live edge can be configured as required on the server itself.

// create asset
val platformAsset = PlatformAsset(
contentId,
MediaType.DASH,
consumptionType,
catalogType,
DrmType.WIDEVINE,
PlaybackMode.LIVE
)

Since the playback is expected to follow real time as much as possible, it does not require a start or end time to be passed by the application.

Restart mode

Restart mode should be used to allow joining a live stream that has already started. In this mode, the entire length of the live stream i.e. from start time to live edge is available for the player. The start time from which the player should be able to play must be passed to the SDK by the application using PlatformAsset. The startTime and endTime must be in ISO8601 string format.

// create asset
val platformAsset = PlatformAsset(
contentId,
MediaType.DASH,
consumptionType,
catalogType,
DrmType.WIDEVINE,
PlaybackMode.RESTART,
startTime,
endTime
)

All restart playbacks start from live edge by default.
Set the initial playback time preference to play the restart stream plays from any specific point instead of the Live Edge (real time).

Catchup mode

Catchup mode should be used to allow streaming a live stream that has already ended but is still in the DVR window. In this mode, the entire length of the live stream i.e. from start to end is available for the player. The start and end times from which the player should be able to play must be passed to the SDK by the application using PlatformAsset. The startTime and endTime must be in ISO8601 string format.

// create asset
val platformAsset = PlatformAsset(
contentId,
MediaType.DASH,
consumptionType,
catalogType,
DrmType.WIDEVINE,
PlaybackMode.CATCHUP,
startTime,
endTime
)
note

Player.seekToLiveEdge API would be a no-op while playing catchup stream. If you are looking to jump to current live edge of a Catchup playback, you must re-authorize the playback in Live mode and setup a new player instance.