Skip to content

Commit

Permalink
Fix issue when rendering the initial seconds of a play
Browse files Browse the repository at this point in the history
  • Loading branch information
andremion committed Feb 25, 2024
1 parent b07e99b commit 6b563d7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ internal class AudioPlayerImpl(
}

override fun setTracks(tracks: List<AudioPlayer.Track>) {
require(tracks.isNotEmpty()) { "Tracks list must not be empty" }
if (!controllerFuture.isDone) error("MediaController is not initialized yet")

player.clearMediaItems()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,7 @@ private fun ScreenContent(
)
}

var time by remember { mutableStateOf("") }
LaunchedEffect(uiState.playerState.time) {
// Only update the time if it is not transitioning.
// This is to avoid the UI glitching during the transition,
// because the movable content is gonna re-compose whenever the time changes.
if (!transitionState.isTransitioning) {
time = uiState.playerState.time.format()
}
}
val time = uiState.playerState.time.format()
val timeText = rememberMovableContent(time) { modifier ->
Text(
modifier = modifier.animateBounds(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ internal class AudioPlayerImpl : AudioPlayer {
}

override fun setTracks(tracks: List<AudioPlayer.Track>) {
require(tracks.isNotEmpty()) { "Tracks list must not be empty" }
this.tracks = tracks
setCurrentItem(index = 0)
}
Expand Down

0 comments on commit 6b563d7

Please sign in to comment.