Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract class BaseMediaManager(surfaceBinder: MediaSurfaceBinder?, coroutineContext: CoroutineContext) : MediaManager, CoroutineScope

An abstract implementation for MediaManager

Link copied to clipboard
abstract class BasePlaybackStateRepo(createInitialState: HotStateFlowRepo<PlaybackState>.() -> PlaybackState, coroutineContext: CoroutineContext) : HotStateFlowRepo<PlaybackState>

An abstract ColdStateFlowRepo for managing PlaybackState

Link copied to clipboard

Default implementation of BaseMediaManager

Default implementation of BaseMediaManager

Default implementation of BaseMediaManager

Default implementation of BaseMediaManager

Default implementation of BaseMediaManager for the JS family, backed by an HTMLMediaElement.

Link copied to clipboard
class DefaultMediaPlayer(val surfaceBinder: MediaSurfaceBinder, createPlaybackStateRepo: (CoroutineContext) -> BasePlaybackStateRepo, coroutineContext: CoroutineContext) : MediaPlayer, CoroutineScope

A default implementation of MediaPlayer

Link copied to clipboard

Default implementation of PlayableMedia

Default implementation of PlayableMedia

Default implementation of PlayableMedia

Default implementation of PlayableMedia

Default implementation of PlayableMedia for the JS family, reading live from the player's HTMLMediaElement (held in the registry under id).

Link copied to clipboard

A default implementation of SoundPlayer

A default implementation of SoundPlayer

A default implementation of SoundPlayer

A default implementation of SoundPlayer

A default implementation of SoundPlayer for the JS family, backed by an HTMLAudioElement.

Link copied to clipboard

A MediaSource.Local referencing a bundled/relative file by its URL.

Link copied to clipboard

Manages media playback

Link copied to clipboard
Link copied to clipboard
sealed class MediaSoundError : Error

A SoundPlayer specific error

Link copied to clipboard
actual sealed class MediaSource

The source at which PlayableMedia can be found

actual sealed class MediaSource

The source at which PlayableMedia can be found

expect sealed class MediaSource

The source at which PlayableMedia can be found

actual sealed class MediaSource

The source at which PlayableMedia can be found. On the web a media source is always a URL loaded by an HTMLMediaElement.

Link copied to clipboard
actual data class MediaSurface

A surface on which the video component of a PlayableMedia can be rendered. Exposes a SurfaceHolder to bind to

actual data class MediaSurface

A surface on which the video component of a PlayableMedia can be rendered. Shared across iOS + macOS. A view constructs a MediaSurface (e.g. from its AVPlayerLayer) and binds it to a MediaSurfaceBinder.

expect class MediaSurface

A surface on which the video component of a PlayableMedia can be rendered

actual class MediaSurface

A surface on which the video component of a PlayableMedia can be rendered. On the web this is the id of the DOM element the player's <video> element should be appended to.

Link copied to clipboard
class MediaSurfaceBinder(logger: Logger = defaultLogger)

A bindable handle for a MediaSurface. A view binds the surface it hosts via bind (and detaches it via unbind); the MediaManager — obtained from a MediaPlayer.surfaceBinder — observes the bound surface and renders video onto it. The view drives binding directly, so no host lifecycle awareness is involved.

Link copied to clipboard
typealias MediaSurfaceBinding = (AVPlayer?) -> Unit
Link copied to clipboard

Controller for rendering a PlayableMedia to a MediaSurface

Link copied to clipboard
interface PlayableMedia

A media that can be played by a MediaPlayer

Link copied to clipboard
sealed class PlaybackError : Exception

An Exception that may occur during playback

Link copied to clipboard
sealed interface PlaybackState : KalugaState

A KalugaState of playback

Link copied to clipboard

A StateRepo/MutableStateFlow of PlaybackState

Link copied to clipboard
open class PlaybackStateRepo(mediaManager: MediaManager, coroutineContext: CoroutineContext) : BasePlaybackStateRepo
Link copied to clipboard
data class Resolution(val width: Int, val height: Int)

The screen resolution of a video

Link copied to clipboard

Plays a sound from MediaSource Meant for short low latency audio

Link copied to clipboard
data class TrackInfo(val id: Int, val type: TrackInfo.Type, val language: String)

Info of the track of a PlayableMedia

Link copied to clipboard
data class URLMediaSource(val url: String) : MediaSource

A MediaSource referenced by an (absolute or relative) URL.

Link copied to clipboard

Controller for adjusting the volume

Properties

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

If true this PlayableMedia has a video component

Functions

Link copied to clipboard

Binds this SurfaceView to binder, so a MediaPlayer using that binder renders its video here. The view's MediaSurface is bound while its surface exists and unbound when it is destroyed (and immediately if the surface is already available). Removing the returned SurfaceHolder.Callback from the holder (and calling MediaSurfaceBinder.unbind) stops the binding.

fun AVPlayerLayer.bind(binder: MediaSurfaceBinder)

Binds this AVPlayerLayer to binder so a MediaPlayer using that binder renders its video here. Call MediaSurfaceBinder.unbind to detach. Simplifies non-Compose video layout, mirroring SurfaceView.bind on Android.

fun AVPlayerView.bind(binder: MediaSurfaceBinder)

Binds this AVPlayerView to binder so a MediaPlayer using that binder renders its video here (the view handles its own layout). Call MediaSurfaceBinder.unbind to detach. This is the macOS path for video outside the Compose tree (CMP-macOS-Native has no AppKit interop).

fun AVPlayerViewController.bind(binder: MediaSurfaceBinder)

Binds this AVPlayerViewController to binder so a MediaPlayer using that binder renders its video here (the controller handles its own layout). Call MediaSurfaceBinder.unbind to detach.

Link copied to clipboard
actual fun mediaSourceFromLocalFile(fileName: String, fileType: String): MediaSource.Local

Attempts to create a MediaSource from a file name

actual fun mediaSourceFromLocalFile(fileName: String, fileType: String): MediaSource.Local

Attempts to create a MediaSource from a file name

expect fun mediaSourceFromLocalFile(fileName: String, fileType: String): MediaSource.Local

Attempts to create a MediaSource from a file name

actual fun mediaSourceFromLocalFile(fileName: String, fileType: String): MediaSource.Local

Attempts to create a MediaSource from a file name

Link copied to clipboard

Attempts to create a MediaSource from a url string

Attempts to create a MediaSource from a url string

Attempts to create a MediaSource from a url string

Attempts to create a MediaSource from a url string

Link copied to clipboard
fun MediaSurface(playerView: AVPlayerView): MediaSurface

macOS-only convenience constructor binding an AVPlayer to an AVPlayerView.

fun MediaSurface(viewController: AVPlayerViewController): MediaSurface

Convenience constructor binding an AVPlayer to an AVPlayerViewController.

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.