Skip to content

Commit

Permalink
Fix slider goes to 0 when flow is collect again
Browse files Browse the repository at this point in the history
  • Loading branch information
StaehliJ committed Feb 23, 2024
1 parent 82c7b39 commit f968216
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.transformLatest
Expand Down Expand Up @@ -170,7 +169,7 @@ fun Player.tickerWhilePlayingAsFlow(
*/
fun Player.currentPositionAsFlow(updateInterval: Duration = DefaultUpdateInterval): Flow<Long> =
merge(
if (isPlaying) emptyFlow() else flowOf(currentPosition),
flow { if (!isPlaying) emit(currentPosition) },
tickerWhilePlayingAsFlow(updateInterval).map {
currentPosition
},
Expand Down

0 comments on commit f968216

Please sign in to comment.