Skip to content

Commit

Permalink
Allow seeking while casting (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasBuelens authored Sep 2, 2024
1 parent d8ecb96 commit c95630d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ui/src/main/java/com/theoplayer/android/ui/SeekBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.theoplayer.android.api.cast.chromecast.PlayerCastState

/**
* A seek bar showing the current time of the player, and which seeks the player when clicked or dragged.
Expand All @@ -30,7 +31,10 @@ fun SeekBar(
val seekable = player?.seekable ?: TimeRanges.empty()
val duration = player?.duration ?: Double.NaN
val playingAd = player?.playingAd ?: false
val enabled = seekable.isNotEmpty() && !playingAd
// `player.seekable` is (incorrectly) empty while casting, see #35
// Temporary fix: always allow seeking while casting.
val casting = player?.castState == PlayerCastState.CONNECTED
val enabled = (seekable.isNotEmpty() && !playingAd) || casting

val valueRange = remember(seekable, duration) {
seekable.bounds?.let { bounds ->
Expand Down

0 comments on commit c95630d

Please sign in to comment.