orpheus

A music library for Java: what is playing, controls and synced lyrics, from any source.

Platforms

What each operating system gives the library, what it cannot give, and how the native parts are handled.

What each system provides

  Windows Linux macOS (experimental)
Source class WindowsSessions MprisSource MacNowPlaying
Interface Media sessions (Windows 10 1809+) MPRIS on the session bus Now Playing, through a helper
Sessions One per application One per player Only the application the system elected
Updates Events Events; position read on change and every 5 s while playing Events from the helper
Text, length, cover Yes; cover as image bytes Yes; cover from file: and data: uris, http and https passed on as an unchecked uri Yes
Media kind Reported, but browsers always say music Not reported A weak hint
Play, pause, toggle, stop, next, previous, seek Yes Yes, as the player allows Yes
Shuffle, repeat Yes Yes Commands only; the state is not seen
Rate Yes Yes No
Fast-forward, rewind Yes No No
Volume No Yes No
Native code A Rust library in the jar None A helper script and framework in the jar

On Windows and Linux a control is offered only while the player says it accepts it (Playback.can); stop is always offered on Linux, where players have no flag for it. The macOS helper reports no such flags, so the fixed set above is offered there. Commands never throw.

Application ids

SourceApp.id() is what AppRules matches against:

A rule is split into parts at dots, hyphens, underscores, slashes, spaces and exclamation marks, and matches an id that contains those parts in a row. So spotify matches all three ids above.

Native loading on Windows

The macOS helper

macOS has no public interface for reading what another application plays. The library uses mediaremote-adapter (BSD-3-Clause): a script run by the system’s /usr/bin/perl that loads a small framework. The library starts it as a child process, reads JSON lines from it and stops it with the source. Commands are sent by short-lived child processes.

Transforming the jars

Programs that embed the library often relocate its packages, obfuscate it, or downgrade its bytecode. The library is written to survive that without configuration:

./gradlew :harness:compat runs the jars after repackaging, obfuscation and a downgrade to Java 8 bytecode.

Compatibility with real players

Measured by hand with harness watch; see BENCHMARKS.md for the table and the dates.