Skip to content

Latest commit

 

History

903 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Compose Media Player has moved into Nucleus

This project is not dead: its code now lives in the Nucleus repository, split into media modules that are maintained and released there, still Kotlin Multiplatform (desktop, Android, iOS, web).

dependencies {
    implementation("dev.nucleusframework:nucleus.media-player:3.0.0")   // video: VideoPlayerState, the video surface, subtitles
    // or, for sound only:
    implementation("dev.nucleusframework:nucleus.audio-player:3.0.0")
    // optional:
    implementation("dev.nucleusframework:nucleus.media-session:3.0.0")  // the system's media session (lock screen, notification)
    implementation("dev.nucleusframework:nucleus.media-hls:3.0.0")      // HLS where the OS does not play it (Android, web)
    implementation("dev.nucleusframework:nucleus.media-dash:3.0.0")     // MPEG-DASH
}

→ Migration guide from Compose Media Player · Media documentation

What's new

Compose Media Player covered the basics: open, play, pause, seek, volume, loop, speed, fullscreen, picture-in-picture, external subtitles and metadata. In Nucleus it gained a lot:

  • Playback: playlists, exact or key-frame seek modes, speed with or without pitch, skipped silences, a loudness boost and an equalizer, playback stats.
  • Streaming: HLS on every platform, MPEG-DASH and Smooth Streaming, live streams with a DVR window, audio languages and video variants to choose from, in-stream subtitles, request headers (tokens, cookies), timed metadata.
  • Offline: download files and whole HLS streams for offline playback, with progress.
  • System media controls: lock screen, notification and background playback on Android, Now Playing on macOS and iOS, SMTC on Windows, MPRIS on Linux.
  • Thumbnails: read a frame at any position, without a player.
  • Audio: AudioPlayer now runs on the same engine as the video, so it plays what the video player plays.
  • Behaviour you can rely on: one implementation shared by every platform and checked by the same conformance scenarios. The frame shown after a seek is the one asked for, a failed media no longer blocks the next one, rotated videos are upright, and the desktop composites the video on the GPU instead of copying every frame on the CPU.

See the media documentation and its platform support page for what each OS offers.

You don't need the whole framework

Nucleus is modular: each media module is its own artifact, and only one case needs the rest of Nucleus.

  • Android, iOS and the web: the media modules are a library like any other. No Nucleus application, plugin or window.
  • Audio on the desktop: audio-player works in any JVM app, Compose Desktop included.
  • Video on the desktop is the exception: it runs in Nucleus windows (nucleusApplication). The video is a GPU texture composited in the Compose scene by the Nucleus window runtime, so it scales, clips, blurs and sits under Compose content like any other node, without copying a frame on the CPU. Doing that on AWT, the backend of Compose Desktop's windows, meant hack after hack (a heavyweight SwingPanel that Compose cannot draw over, or a CPU copy of every frame), each one paid for in performance, and too much for me to keep maintaining. Nucleus's window runtime is far more modern and built for exactly this kind of use.

Why it moved

A video player on the desktop depends on everything around it: the window runtime that composites the video into the Compose scene, the native libraries for each OS, packaging, GraalVM native images. Keeping it in its own repository meant following Nucleus from the outside, with its own build, its own CI and its own version.

In the Nucleus repository the player is built, tested and released together with the rest of the framework:

  • One version for everything: the player you depend on is the one tested against the window runtime and the plugin of the same release.
  • A pipeline made for native libraries and every target: Nucleus's CI builds the native libraries for Windows, macOS and Linux (x64 and ARM64) on every change and publishes every Kotlin Multiplatform target, iOS included. The player runs a conformance suite of scenarios on every platform (open, seek to the frame, errors and recovery, HLS, headers, tracks…), and many of the bugs reported here are now scenarios that fail if they come back.
  • Easier to maintain: one place to fix a bug, one changelog, one issue tracker.

The engine was rewritten on that occasion so that every platform behaves the same, and the desktop no longer copies frames on the CPU.

Where things are now

  • Code: the media-engine, media-player, audio-player, media-session, media-hls, media-dash and media-smoothstreaming modules of the Nucleus repository.
  • Issues and pull requests: Nucleus issues. The issues open here were reviewed: those solved in Nucleus are closed with a pointer, those still relevant were opened again in Nucleus.
  • Old code: the last version of this repository (0.11.4 and its history) is kept, read-only, on the archive branch. Published versions stay on Maven Central (io.github.kdroidfilter:composemediaplayer, composemediaplayer-audio).

License

MIT, see LICENSE. Nucleus is MIT as well.