Controls

data class Controls(val play: MediaPlayer.Controls.Play? = null, val pause: MediaPlayer.Controls.Pause? = null, val unpause: MediaPlayer.Controls.Unpause? = null, val stop: MediaPlayer.Controls.Stop? = null, val seek: MediaPlayer.Controls.Seek? = null, val setRate: MediaPlayer.Controls.SetRate? = null, val setLoopMode: MediaPlayer.Controls.SetLoopMode? = null, val awaitPreparation: MediaPlayer.Controls.AwaitPreparation? = null, val displayError: MediaPlayer.Controls.DisplayError? = null)

The controls available to manage playback on a MediaPlayer

Constructors

Link copied to clipboard
constructor(play: MediaPlayer.Controls.Play? = null, pause: MediaPlayer.Controls.Pause? = null, unpause: MediaPlayer.Controls.Unpause? = null, stop: MediaPlayer.Controls.Stop? = null, seek: MediaPlayer.Controls.Seek? = null, setRate: MediaPlayer.Controls.SetRate? = null, setLoopMode: MediaPlayer.Controls.SetLoopMode? = null, awaitPreparation: MediaPlayer.Controls.AwaitPreparation? = null, displayError: MediaPlayer.Controls.DisplayError? = null)

Types

Link copied to clipboard
Link copied to clipboard
sealed class ControlType

A type of control to manage playback on a MediaPlayer

Link copied to clipboard

A ControlType that indicates a MediaPlayer is in an error state

Link copied to clipboard
class Pause(val perform: suspend () -> Unit) : MediaPlayer.Controls.ControlType

A ControlType that allows a MediaPlayer to be paused

Link copied to clipboard

A ControlType that allows a MediaPlayer to be started

Link copied to clipboard
class Seek(val perform: suspend (Duration) -> Boolean) : MediaPlayer.Controls.ControlType

A ControlType that allows a MediaPlayer to seek its current playback to a given Duration

Link copied to clipboard
class SetLoopMode(val currentLoopMode: PlaybackState.LoopMode, val perform: suspend (PlaybackState.LoopMode) -> Unit) : MediaPlayer.Controls.ControlType

A ControlType that provides and adjusts the PlaybackState.LoopMode of the current playback of a MediaPlayer

Link copied to clipboard
class SetRate(val currentRate: Float, val perform: suspend (Float) -> Unit) : MediaPlayer.Controls.ControlType

A ControlType that provides and adjusts the rate of the current playback of a MediaPlayer

Link copied to clipboard
class Stop(val perform: suspend () -> Unit) : MediaPlayer.Controls.ControlType

A ControlType that allows a MediaPlayer to be stopped

Link copied to clipboard
class Unpause(val perform: suspend () -> Unit) : MediaPlayer.Controls.ControlType

A ControlType that allows a MediaPlayer to be resumed after being paused

Properties

Link copied to clipboard
Link copied to clipboard

A set of all ControlType currently available

Link copied to clipboard
Link copied to clipboard

the Pause control available

Link copied to clipboard

the Play control available

Link copied to clipboard

the Seek control available

Link copied to clipboard

the SetLoopMode control available

Link copied to clipboard

the SetRate control available

Link copied to clipboard

the Stop control available

Link copied to clipboard

the Unpause control available

Functions

Link copied to clipboard

Gets a given ControlType if available

Link copied to clipboard
suspend fun tryPause(): Boolean

Attempts to do Pause.perform on pause if it exists

Link copied to clipboard
suspend fun tryPlay(playbackParameters: PlaybackState.PlaybackParameters = PlaybackState.PlaybackParameters()): Boolean

Attempts to do Play.perform on play if it exists

Link copied to clipboard
suspend fun trySeek(duration: Duration): Boolean

Attempts to do Seek.perform on seek if it exists

Link copied to clipboard

Attempts to do SetLoopMode.perform on setLoopMode if it exists

Link copied to clipboard
suspend fun trySetRate(rate: Float): Boolean

Attempts to do SetRate.perform on setRate if it exists

Link copied to clipboard
suspend fun tryStop(): Boolean

Attempts to do Stop.perform on stop if it exists

Link copied to clipboard
suspend fun tryUnpause(): Boolean

Attempts to do Unpause.perform on unpause if it exists