Compose Multiplatform extensions for media: hosts the platform-native video surface inside the Compose tree.
Installing
This library is available on Maven Central. You can import Kaluga Media Compose as follows:
repositories {
// ...
mavenCentral()
}
// ...
dependencies {
// ...
implementation("com.splendo.kaluga:media-compose:$kalugaVersion")
}
Usage
Check out the full documentation
Create a ComposeMediaSurfaceProvider, hand it to a MediaManager, and render it inside Compose via MediaSurfaceContainer. The container creates the platform surface and pushes it into the provider; the surface is detached on composition exit.
val provider = ComposeMediaSurfaceProvider()
val mediaPlayer = DefaultMediaPlayer(provider, baseMediaManagerBuilder, Dispatchers.Main)
@Composable
fun VideoScreen() {
MediaSurfaceContainer(provider, modifier = Modifier.fillMaxSize())
}
This is the inverse of the platform “walk the view tree to find a SurfaceView” providers — useful when the host is Compose rather than an Activity or UIViewController.
Platform notes
- Android — wraps an
AndroidView { SurfaceView(...) }and pushes itsSurfaceHolderinto the provider. - iOS — hosts an
AVPlayerView-backedUIViewviaUIKitView. - macOS — placeholder. CMP-macOS-Native (1.11) ships no
NSViewinterop, so video playback inside Compose-on-macOS is not yet supported. Use the nativeNSViewMediaSurfaceProvider/WindowLifecycleSubscribablefrommediaagainst an AppKitAVPlayerViewhosted outside the Compose tree.