Skip to content

Commit

Permalink
[Jetcaster] Allow Slider seeking player (#1374)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlykotom committed Apr 29, 2024
2 parents ac8340d + bd334fa commit 0510149
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 109 deletions.
Expand Up @@ -103,6 +103,16 @@ interface EpisodePlayer {
*/
fun rewindBy(duration: Duration)

/**
* Signal that user started seeking.
*/
fun onSeekingStarted()

/**
* Seeks to a given time interval specified in [duration].
*/
fun onSeekingFinished(duration: Duration)

/**
* Increases the speed of Player playback by a given time specified in [duration].
*/
Expand Down
Expand Up @@ -173,6 +173,17 @@ class MockEpisodePlayer(
}
}

override fun onSeekingStarted() {
// Need to pause the player so that it doesn't compete with timeline progression.
pause()
}

override fun onSeekingFinished(duration: Duration) {
val currentEpisodeDuration = _currentEpisode.value?.duration ?: return
timeElapsed.update { duration.coerceIn(Duration.ZERO, currentEpisodeDuration) }
play()
}

override fun increaseSpeed(speed: Duration) {
_playerSpeed.value += speed
}
Expand Down

0 comments on commit 0510149

Please sign in to comment.