Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ open class DefaultVideoPlayerState: VideoPlayerState {
override var playbackSpeed: Float
get() = _playbackSpeed
set(value) {
_playbackSpeed = value.coerceIn(0.5f, 2.0f)
_playbackSpeed = value.coerceIn(VideoPlayerState.MIN_PLAYBACK_SPEED, VideoPlayerState.MAX_PLAYBACK_SPEED)
exoPlayer?.let { player ->
player.playbackParameters = PlaybackParameters(_playbackSpeed)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ interface VideoPlayerState {
var loop: Boolean
var playbackSpeed: Float

companion object {
const val MIN_PLAYBACK_SPEED = 0.25f
const val MAX_PLAYBACK_SPEED = 2.0f
}

/**
* Provides the audio level for the left channel as a percentage.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ open class DefaultVideoPlayerState: VideoPlayerState {
override var playbackSpeed: Float
get() = _playbackSpeed
set(value) {
_playbackSpeed = value.coerceIn(0.5f, 2.0f)
_playbackSpeed = value.coerceIn(VideoPlayerState.MIN_PLAYBACK_SPEED, VideoPlayerState.MAX_PLAYBACK_SPEED)
// Only update player rate if we are playing to avoid auto-play
if (_isPlaying) {
player?.rate = _playbackSpeed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class LinuxVideoPlayerState : VideoPlayerState {
override var playbackSpeed: Float
get() = _playbackSpeedState.value
set(value) {
val newValue = value.coerceIn(0.5f, 2.0f)
val newValue = value.coerceIn(VideoPlayerState.MIN_PLAYBACK_SPEED, VideoPlayerState.MAX_PLAYBACK_SPEED)
if (_playbackSpeedState.value != newValue) {
_playbackSpeedState.value = newValue
ioScope.launch { applyPlaybackSpeed() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class MacVideoPlayerState : VideoPlayerState {
override var playbackSpeed: Float
get() = _playbackSpeedState.value
set(value) {
val newValue = value.coerceIn(0.5f, 2.0f)
val newValue = value.coerceIn(VideoPlayerState.MIN_PLAYBACK_SPEED, VideoPlayerState.MAX_PLAYBACK_SPEED)
if (_playbackSpeedState.value != newValue) {
_playbackSpeedState.value = newValue
// Launch a coroutine to apply the playback speed if the native player is available.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class WindowsVideoPlayerState : VideoPlayerState {
override var playbackSpeed: Float
get() = _playbackSpeed
set(value) {
val newSpeed = value.coerceIn(0.5f, 2.0f)
val newSpeed = value.coerceIn(VideoPlayerState.MIN_PLAYBACK_SPEED, VideoPlayerState.MAX_PLAYBACK_SPEED)
if (_playbackSpeed != newSpeed) {
_playbackSpeed = newSpeed
scope.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ open class DefaultVideoPlayerState: VideoPlayerState {
override var playbackSpeed: Float
get() = _playbackSpeed
set(value) {
val newValue = value.coerceIn(0.5f, 2.0f)
val newValue = value.coerceIn(VideoPlayerState.MIN_PLAYBACK_SPEED, VideoPlayerState.MAX_PLAYBACK_SPEED)
if (_playbackSpeed != newValue) {
_playbackSpeed = newValue
applyPlaybackSpeedWithThrottle(newValue)
Expand Down
Loading