The best video player for Compose Multiplatform is...
# feed
u
The best video player for Compose Multiplatform is back 🎬 ComposeMediaPlayer v0.9.0 — and this is not a small update. The desktop backend has been rewritten under the hood. Zero external dependencies, all gone. macOS, Linux and Windows now run on full JNI with native C/C++/Swift compiled and embedded directly in the lib. The result: massive performance boost on desktop. The native backend now returns frames already in the exact format requested by Compose — no more CPU-side rescaling. Here's what's new: • Picture-in-Picture (Android & iOS) • HLS streaming on Desktop •
openAsset()
API for bundled media files • Opt-in video caching (Android & iOS) • Seek API,
restart()
,
onPlaybackEnded
,
duration
• Configurable audio session mode (iOS & Android) • Playback speed down to 0.25x • Sample app redesigned with Material3 + a ton of fixes across all platforms. 👉 https://github.com/kdroidFilter/ComposeMediaPlayer/releases/tag/v0.9.0
🎉 16
🚀 8
🔥 6
thank you color 6
d
What if one needs to configure media3 for android to support background playing, ads etc... do you support overriding the player instance? Also, does the library have player events the app can react to?
u
@dave08 I have a PR in progress for background playing support. The current configuration does not natively support the insertion of advertisements via Media3; I think that this kind of use is already too niche to use a cross-platform abstraction and that the native library should be used for this kind of use. The lib exposes several states and callbacks that your application can respond to via the
playerState
object: `onPlaybackEnded`: Triggered when the video reaches the end. `onRestart`: Called when the video restarts (if loop mode is enabled). `error`: An observable state that contains details in case of a playback failure. `isLoading`: A boolean to indicate whether the player is loading or buffering. `isPlaying`: To track the playback state in real time.
d
Wouldn't it be possible to just allow the user to provide the Player instance (a MediaController) if they need to customize media3? It would be their responsibility to handle not breaking configs, but it's a bit like what Ktor client does... that would allow a lot more flexibility.
u
The idea is appealing on paper, but in practice it's too complex to maintain cleanly. The lib internally manages the entire player lifecycle (listeners, error recovery, state synchronization, audio handling, cache...) — accepting an external player would break too many internal contracts and become a source of hard-to-diagnose bugs. For truly advanced use cases like ads, I think it falls outside the scope of a cross-platform abstraction and it's healthier to use Media3 directly on the Android side.
d
yeah, my problem is re-implementing the other platforms... I currently have a common code "driver" interface that needs to be implemented for android/ios/desktop/wasmJs, the android one is pretty good with media3, but the other ones are quite complex to implement in a way that they behave nicely with compose layouts etc... I was really hoping for some kind of low-level library that could handle that.
In theory, if it would be possible to extract the low-level logic in a separate module somehow and have the main lib depend on that, it could open up tons of possibilities w/o over designing the high-level player... some already have some kind of PlayerSurface etc... and just need the basic plumbing.
u
That's an interesting idea architecturally, but in practice the low-level plumbing (native surfaces, Compose rendering bridge) and the player logic (listeners, state sync, lifecycle) are tightly coupled in the current implementation. Splitting them into separate modules would require a significant refactoring effort and introduce an additional public API to maintain. It's not off the table as a long-term goal, but right now the priority is getting the core player solid and consistent across all platforms. The demand for that kind of low-level access is pretty niche, so it's hard to justify the effort at this stage. (especially since the project doesn't receive any funding).
d
Fair enough, thanks anyways!
149 Views