Skip to content

[BUG]: [IOS] HLS Live time incorrect, difficulty to get Live time. #4415

Closed
@guyhguy25

Description

@guyhguy25

Version

6.10.0

What platforms are you having the problem on?

iOS

System Version

18.2

On what device are you experiencing the issue?

Real device

Architecture

Old architecture

What happened?

I did some testing around and found out that on iOS it's not easy to get the live timing of the HLS video.

onProgress giving us those values:

  1. currentTime
  2. playableDuration
  3. seekableDuration

on Android(ExoPlayer) when streaming live HLS video, the currentTime will buffer around the seekableDuration
fe:
seekableDuration: 3600(1hr)
currentTime: 3590 -> 3591 -> 3592 -> 3593 -> 3594 -> 3595 -> 3590

so when trying to calculate the user position on Android this is what we do:
currentTime / seekableDuration to get the "currentOffsetFromLive"

on iOS, however, the formula would not work, as the currentTime scale is infinite.
fe:
seekableDuration: 3600(1hr)
currentTime: 3595 -> 3596 -> 3597 -> 3598 -> 3599 -> 3600 -> 3601 -> and so on till video restarted.

you can look at that this way:

|------------------------------------------------------------|
0-----------------------------------------------------------Live

5 min later: (the 5 min becomes the 0 position)

|-------------------------------------------------------------------|
0---------5 min-------------------------------Old Live(5min)---Live

If I seek to 0, the AVPlayer will reseek me to 5 minutes, so it is like 5 minutes of the seek bar is not reachable.
and when I try to reach the current Live after 5 minutes,
I will be at: "Old Live" not the new one which is 3600 + 300(5 min)

(I tried a few tricks like: updating the duration each time inside onProgress by 0.250 as the progressUpdateInterval is, but then we need to find a solution to lose a second at the start of the stream, cause the way it works the start of the video is keep increasing as well by default)

It has a solution, but it requires using the epoch value, currentPlaybackTime and always getting a new date to know what time is now and what time the video is, and then doing a calculation to find the currentOffsetFromLive.

that's one problem, the second one is getting back to Live.
if you take AVplayer without anything, only controls, and stream live HLS, you will see after a few minutes played if you try using the seek bar to get back to live, it is not possible (it will take you to the live time when you start watching the live) and the only way is by clicking: "Jump to Live" by AVplayer controls.

I think I found a solution for the second one, I need to test it. If it works I may pull request it.

Reproduction Link

https://github.com/guyhguy25/hls-video-test

Reproduction

Step to reproduce this bug are:
just stream a HLS live video, you will see it in onProgress

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions