Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated from 0.14.9: Auto-seeking to the latest segment on playback doesn't work anymore #5678

Closed
junpark-liveconnect opened this issue Jul 18, 2023 · 4 comments

Comments

@junpark-liveconnect
Copy link

What do you want to do with Hls.js?

I used 0.14.9 before and now migrating to 1.4.x.

When using version 0.14.9, if playback was initiated after a few minutes of loading, it automatically jumped to the latest segment and started playing. However, in the current version, playback starts from the paused segment even after 10 minutes of loading.

The config parameters are still provided in the same way. With the version upgrade, is there a specific config parameter that needs to be manually set to enable this feature(auto-seeking)?

What have you tried so far?

I tried liveMaxLatencyDuration, but it periodically seeks based on the amount of loaded segments, regardless of user action. This is different from seeking to a specific segment only after playback that I intend.

@junpark-liveconnect junpark-liveconnect added Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. Question labels Jul 18, 2023
@robwalch
Copy link
Collaborator

robwalch commented Jul 18, 2023

Hi @junpark-liveconnect,

liveMaxLatencyDuration dictates whether HLS.js will seek or not when paused in a live stream as the playlist advances. If set to Infinity, or a very large value, HLS.js will not seek as long as there is buffer to play through. After resuming and playing through the available buffer, if a gap is encountered, and playback is not within the live window, HLS.js should resync with the live stream.

One way to clear the back buffer as live streams updates is to set backBufferLength. If your live stream has a window of 60 seconds, set backBufferLength to 60. If resuming playback and the buffer is empty, HLS.js should resync with the live stream.

Another solution would be to listen for "play" events on the media element, and set currentTime to seek to the live edge as you see fit.

@robwalch robwalch added answered and removed Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Jul 18, 2023
@junpark-liveconnect
Copy link
Author

junpark-liveconnect commented Jul 24, 2023

Thanks for quick reply, @robwalch !
I found _ensureFragmentAtLivePoint function is running every tick in v0.14.9 which is not running anymore in v1.4.x.
To jump to live edge StreamController used liveSyncPosition. I searched and found HLS has liveSynsPosition field.
I use the statement video.currentTime = hls.liveSyncPosition every time it plays as the last solution you mentioned and it works how I expected.

So can I say it doesn't move to live edge automatically without the code like this?

@robwalch
Copy link
Collaborator

robwalch commented Jul 24, 2023

I found _ensureFragmentAtLivePoint function is running every tick in v0.14.9 which is not running anymore in v1.4.x.

In v1, synchronizeToLiveEdge is evaluated with every tick the same way that _ensureFragmentAtLivePoint was. The difference is that synchronizeToLiveEdge will not seek forward while there is media in the buffer that can still be played (media.readyState is 4). This allows resumption without jumping ahead automatically which was not possible before.

The change was introduced with this PR:

Based on live sync cleanup made here:

With issues and discussion covered in these issues to name a few:

To jump to live edge StreamController used liveSyncPosition. I searched and found HLS has liveSynsPosition field.
I use the statement video.currentTime = hls.liveSyncPosition every time it plays as the last solution you mentioned and it works how I expected.

This is an acceptable solution. The same that would be required if you wanted the same behavior playing HLS natively in Safari, which was the motivation for the change.

So can I say it doesn't move to live edge automatically without the code like this?

Yes. This change was made intentionally. There was no effort to maintain the old behavior as it better achieves with the HTMLMediaElement API outside of HLS.js.

@junpark-liveconnect
Copy link
Author

Thank you for details again.

Now I understand how it went thru all.

I'll close this. :)

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

No branches or pull requests

2 participants