Skip to main content

Module mpris

Module mpris 

Expand description

MPRIS — org.mpris.MediaPlayer2 desktop media control, in the toolkit.

Shared, app-agnostic core that publishes now-playing metadata + transport state to the desktop and receives media-key / system-widget commands back. Lifted out of the Music app so any ui consumer (e.g. ui::widget::video_player::VideoPlayer, hence Tube) gets this free.

This is the pure state/command core; it always compiles so tests run without D-Bus. The session itself comes from the host’s crate::host::MediaSessionFactory — natively, D-Bus serving in ui::native::mpris, which requires Unix and the mpris feature. Other hosts and platforms leave the handle inactive.

Two channels bridge the session to the widget: external commands land as MprisCommands drained each frame (MprisHandle::drain_commands); the widget pushes a PlayerSnapshot on change (MprisHandle::publish) and the session emits PropertiesChanged.

Structs§

MprisConfig
Identity for the served MPRIS bus: the well-known name + human-readable player name, so different consumers (Music, Tube, the local video player) present distinctly in the system media widget.
MprisHandle
The widget-side handle to the host’s media controls, started through the current crate::host::MediaSessionFactory. When the host has none — the default (non-mpris) build, non-Unix platforms, no session bus, headless hosts — this is an inert stub: publish is a no-op and drain_commands yields nothing, so the widget code path is identical everywhere.
PlayerSnapshot
A snapshot of everything MPRIS exposes about the player.

Enums§

MprisCommand
A control request arriving from an external MPRIS client (media keys, the GNOME media widget, playerctl, …).
PlaybackStatus
Transport state, mapped to the MPRIS PlaybackStatus string.

Constants§

OBJECT_PATH
The single object path both MPRIS interfaces live at.

Functions§

track_object_path
Map a track id to a valid D-Bus object path for mpris:trackid. D-Bus paths allow only [A-Za-z0-9_] between / separators, so non-conforming bytes are replaced with _. An empty id yields the MPRIS “no track” sentinel path.