Skip to content

Commit

Permalink
Rename method to currentPositionPercentage
Browse files Browse the repository at this point in the history
To fit media3 naming.
  • Loading branch information
StaehliJ committed Sep 13, 2023
1 parent b947ffc commit 724fb12
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ fun Player.getPlaybackSpeed(): Float {
*
* @return the current position in percent [0,1].
*/
fun Player.currentPositionPercent(): Float {
fun Player.currentPositionPercentage(): Float {
return currentPosition / duration.coerceAtLeast(1).toFloat()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import androidx.media3.common.Player
import ch.srgssr.pillarbox.player.availableCommandsAsFlow
import ch.srgssr.pillarbox.player.canSeek
import ch.srgssr.pillarbox.player.currentPositionAsFlow
import ch.srgssr.pillarbox.player.currentPositionPercent
import ch.srgssr.pillarbox.player.currentPositionPercentage
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.collectLatest
Expand All @@ -30,7 +30,7 @@ import kotlinx.coroutines.flow.map
*/
@Stable
class ProgressTracker internal constructor(private val player: Player) {
private val playerProgressPercent: Flow<Float> = player.currentPositionAsFlow().map { player.currentPositionPercent() }
private val playerProgressPercent: Flow<Float> = player.currentPositionAsFlow().map { player.currentPositionPercentage() }
private val userSeekState = MutableStateFlow<UserSeekState>(UserSeekState.Idle)
private val canSeek = player.availableCommandsAsFlow().map { it.canSeek() }
private val progressPercentFlow: Flow<Float> = combine(userSeekState, playerProgressPercent) { seekState, playerProgress ->
Expand All @@ -46,7 +46,7 @@ class ProgressTracker internal constructor(private val player: Player) {
* @return progress percent as State.
*/
@Composable
fun progressPercent(): State<Float> = progressPercentFlow.collectAsState(initial = player.currentPositionPercent())
fun progressPercent(): State<Float> = progressPercentFlow.collectAsState(initial = player.currentPositionPercentage())

/**
* Can seek
Expand Down

0 comments on commit 724fb12

Please sign in to comment.