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

802 player time api #814

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

802 player time api #814

wants to merge 9 commits into from

Conversation

StaehliJ
Copy link
Contributor

@StaehliJ StaehliJ commented Nov 27, 2024

Pull request

Description

The goal of this PR is to provide API and helper to better handle timestamp based stream. Streams may have timestamps information inside their playlist. Media3 is able to extract those informations inside the Timeline.Window.

Pillarbox provide helper to manipulate time based on that information. Those API work only and only if there are timestamp information. Pillarbox doesn't make magic with live streams that haven't timestamp inside the stream.

Changes made

  • Add Player. getUnixTimeMs.
  • Add Player. seekToUnixTimeMs.

Checklist

  • APIs have been properly documented (if relevant).
  • The documentation has been updated (if relevant).
  • New unit tests have been written (if relevant).
  • The demo has been updated (if relevant).

@StaehliJ StaehliJ linked an issue Nov 27, 2024 that may be closed by this pull request
1 task
Copy link

github-actions bot commented Nov 27, 2024

Code Coverage

Overall Project 48.58% -0.12% 🟢
Files changed 57.95% 🟢

Module Coverage
:pillarbox-player 56.49% -0.23% 🟢
Files
Module File Coverage
:pillarbox-player ErrorMessageData.kt 49.71% -1.16% 🟢
Player.kt 36.19% -13.06% 🟢

@StaehliJ StaehliJ marked this pull request as ready for review November 28, 2024 13:07
/**
* Local time formatter that format [LocalTime] to HH:mm:ss.
*/
val localTimeFormatter by lazy {
Copy link
Member

Choose a reason for hiding this comment

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

Update CountdownView to use this formatter, since it defined its own with the same configuration?

@@ -306,9 +312,15 @@ private fun PlayerTimeRow(
var compactMode by remember {
mutableStateOf(true)
}
val isLive by player.isCurrentMediaItemLiveAsState()
val positionTime = if (isLive) player.getUnixTimeMs(positionMs) else C.TIME_UNSET
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we pass a Window to getUnixTimeMs()?

Comment on lines +38 to +40
LaunchedEffect(player) {
player.play()
}
Copy link
Member

Choose a reason for hiding this comment

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

Why not use a LifecycleEffect here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✏️ Draft
Development

Successfully merging this pull request may close these issues.

Player time API
2 participants