Skip to content

Commit

Permalink
Simplify initial seek
Browse files Browse the repository at this point in the history
  • Loading branch information
damontecres committed Feb 14, 2024
1 parent 1ecb3f2 commit 77e380f
Showing 1 changed file with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,18 @@ class PlaybackExoFragment :
if (videoView.controllerShowTimeoutMs > 0) {
videoView.hideController()
}
exoPlayer.addListener(
object : Player.Listener {
private var initialSeek = true

override fun onAvailableCommandsChanged(availableCommands: Player.Commands) {
if (initialSeek && position > 0 && Player.COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM in availableCommands) {
exoPlayer.seekTo(position)
initialSeek = false
exoPlayer.removeListener(this)
if (position > 0) {
exoPlayer.addListener(
object : Player.Listener {
override fun onAvailableCommandsChanged(availableCommands: Player.Commands) {
if (Player.COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM in availableCommands) {
exoPlayer.seekTo(position)
exoPlayer.removeListener(this)
}
}
}
},
)
},
)
}
}
}

Expand Down

0 comments on commit 77e380f

Please sign in to comment.