Types

Link copied to clipboard
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

Properties

Link copied to clipboard
abstract val controls: Flow<MediaPlayer.Controls>

A Flow of the Controls available for playback

Link copied to clipboard
abstract val currentVolume: Flow<Float>

The volume of the audio playback. A value of 0.0 indicates silence; a value of 1.0 (the default) indicates full audio volume for the player instance.

Link copied to clipboard

A Flow that provides the Duration of the current PlayableMedia of a MediaPlayer. If no PlayableMedia is loaded this will result in Duration.ZERO.

Link copied to clipboard
abstract val playableMedia: Flow<PlayableMedia?>

A Flow of the PlayableMedia for which the player is controlling playback

Functions

Link copied to clipboard
abstract suspend fun awaitCompletion()

Suspends until playback has completed

Link copied to clipboard
abstract fun close()

Releases all resources associated with the media player. This method should be called when done with the media player. After calling this playback is disabled. Any subsequent calls will result in a PlaybackError.PlaybackHasEnded

Link copied to clipboard
abstract suspend fun forceStart(playbackParameters: PlaybackState.PlaybackParameters, restartIfStarted: Boolean = false)

Suspends until playback has started.

Link copied to clipboard
abstract suspend fun initializeFor(source: MediaSource)

Loads a MediaSource into a PlayableMedia to control playback for

Link copied to clipboard
suspend fun MediaPlayer.play(playbackParameters: PlaybackState.PlaybackParameters = PlaybackState.PlaybackParameters(), restartIfStarted: Boolean = false)

Forces the MediaPlayer to start playback and suspends until playback has completed

Link copied to clipboard
fun MediaPlayer.playTime(pollingInterval: Duration): Flow<Duration>

A Flow that polls the playtime of the current PlayableMedia of a MediaPlayer as a Duration. If no PlayableMedia is loaded this will result in Duration.ZERO.

Link copied to clipboard
abstract suspend fun renderVideoOnSurface(surface: MediaSurface?)

Renders the video component of any initialized PlayableMedia on a MediaSurface

Link copied to clipboard
abstract suspend fun reset()

Stops current playback and resets the player.

Link copied to clipboard
abstract suspend fun updateVolume(volume: Float)

Updates the currentVolume