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§
- Mpris
Config - 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.
- Mpris
Handle - 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:publishis a no-op anddrain_commandsyields nothing, so the widget code path is identical everywhere. - Player
Snapshot - A snapshot of everything MPRIS exposes about the player.
Enums§
- Mpris
Command - A control request arriving from an external MPRIS client (media keys, the
GNOME media widget,
playerctl, …). - Playback
Status - Transport state, mapped to the MPRIS
PlaybackStatusstring.
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.