Skip to content

Fix livestreams#2627

Open
CranberrySoup wants to merge 1 commit intorecloudstream:masterfrom
CranberrySoup:fix_live
Open

Fix livestreams#2627
CranberrySoup wants to merge 1 commit intorecloudstream:masterfrom
CranberrySoup:fix_live

Conversation

@CranberrySoup
Copy link
Copy Markdown
Contributor

  • Fixes the issue of live streams closing if you seek too far (PlaylistStuckException).
  • Removes previews from live streams (they get outdated)
  • Changes seekbar to display as full when you are sufficiently live.
  • Seeking beyond the optimal live point makes the player seek back to the optimal live point

Knowing when the user is live is actually difficult, because most livestreams are only a sliding window of 10-30 second media segments. I therefore have to calculate where the optimal player point is based on new video chunks and their durations.

From my testing it works well on all livestreams, with the caveat of the seekbar not being very useful in short live streams due to the auto-seek. I did not see a good way to circumvent this, and the seekbar is currently useless in short live streams regardless.

This could potentially fail on specially crafted live streams, but it would at worst make the video unseekable.

) {
// We want to be PREFERRED_LIVE_OFFSET ms after the latest update, but we cannot be ahead of the middle point.
// If we are ahead of the middle point we will reach the end before the new chunk is expected to be released.
val targetPosition = maxOf(0,minOf(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be calculated using an average of several chunks. It would increase accuracy by a bit but increase complexity.


object LiveHelper {
private val liveManagers = WeakHashMap<Player, LiveManager>()
private val listeners = WeakHashMap<Player, Player.Listener>()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would make more sense as a Pair, to make them synced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants