SeekBarState

State holder for a seek bar, such as SeekBar.

While the user drags the seek bar (see onValueChange), the player is temporarily paused, and resumed on onValueChangeFinished if it was playing. To avoid loading media for positions that are scrubbed past, the player only seeks once the user stops moving for a moment, or when they finish.

This is also a PlaybackTimeState, whose currentTime is the scrub position while scrubbing.

Create an instance with rememberSeekBarState.

Properties

Link copied to clipboard
open override val currentTime: Double

The current playback position of the media, in seconds. While the user is scrubbing, this is the scrubTime.

Link copied to clipboard

The duration of the media, in seconds.

Link copied to clipboard

Whether the seek bar can be interacted with.

Link copied to clipboard

The position the user is scrubbing to, in seconds, or null if the user is not scrubbing.

Link copied to clipboard

Whether to show the seek bar's thumb. Hidden while an ad is playing.

Link copied to clipboard

The StreamType of the media.

Link copied to clipboard

The current scrub position of the seek bar, relative to the start of seekableRange.

Link copied to clipboard

The range of value. Always starts at zero.

Functions

Link copied to clipboard
fun onValueChange(value: Float)

Called while the user drags the seek bar. Temporarily pauses a playing player, and seeks to the given position within valueRange once the user stops dragging for a moment.

Link copied to clipboard

Called when the user stops dragging the seek bar. Seeks to the final position, and resumes playback if the player was playing before the drag started.

Link copied to clipboard
fun seekTo(value: Float)

Seeks to a position within valueRange without changing playback state.

Link copied to clipboard

Plays or pauses the player. While the user is scrubbing, this instead changes whether playback resumes when scrubbing finishes.