Joey Moto
Joey Moto

Reputation: 49

Exoplayer- how to immediately trigger a BehindLiveWindowException after pausing/resuming a live stream outside live window

My live window is approximately 10 minutes, my buffer is about 30 seconds. If I pause the stream for longer than 10 minutes then resume, the player will play the buffered data for ~30 secs before throwing a BehindLiveWindowException.

Instead, is there a way to anticipate ahead of the buffer for a possible BehindLiveWindowException so that we can receive the error straight away? I've tried looking online but there's very little on this topic.

Upvotes: 0

Views: 765

Answers (1)

Joey Moto
Joey Moto

Reputation: 49

    override fun onTimelineChanged(timeline: Timeline, reason: Int) {
    if (timeline.isEmpty) {
      earliestLiveWindowTime = LIVE_WINDOW_UNSET
      return
    }

    val window = timeline.getWindow(0, timelineWindow, 0)
    earliestLiveWindowTime = window.windowStartTimeMs
  }

Regarding the above code, earliestLiveWindowTime will be the earliest time available of the live window. When resuming after having paused for a while, if the player position is a lower value than this earliestLiveWindowTime value, we know that we're behind the live window so can throw a BehindLiveWindowException at this point.

Upvotes: 2

Related Questions