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

Allows exact live sync for HLS #1752

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

stevemayhew
Copy link
Contributor

This pull request satisfies the enhancement request #702. For playback longer than a few hours the fix for SntpClient is also required, see pull request #697

This commit addresses the issue of inaccurate live position measurement in HLS
by introducing NTP time synchronization. Unlike DASH, HLS lacks origin time
synchronization logic, resulting in potential discrepancies in wall-clock time
when using `System.currentTimeMillis()`.

The commit utilizes the `SntpClient` in ExoPlayer to determine the clock offset
with the default NTP server (`time.android.com`) and applies this information to the `HlsMediaSource`.

With the implementation of this change, multiple devices can now synchronize playback to
a common time source, as long as the origin server also synchronizes to an NTP time source.
Enables testing the Live Offset settings with the main demo PlayerActivity.  Using an
intent like:

```
adb shell am start -n androidx.media3.demo.main/.PlayerActivity -a androidx.media3.demo.main.action.VIEW --ei live_offset_target 30 --ef live_offset_adjust_speed 35.0
```

Will start playback synced to a 30 second offset with agressive speed adjustment to achive it, note
this requires audio codec that supports speed changes (AAC for example)
@tonihei tonihei self-assigned this Sep 27, 2024
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