MPRIS: media players with metadata, controls, TrackList and Playlists.
local player = mantle.mpris:map(function(mpris)
return mpris.players[1]
end)
rect {
on_click = function()
local current = player:get()
if current then
mantle.mpris:control(current.id, "play_pause")
end
end,
children = {
text {
max_width = 240,
elide = "end",
content = player:map(function(current)
return current and (current.play_state .. ": " .. current.title) or ""
end, ""),
},
},
}
Cover art as an existing local path, or empty when unavailable.
album_artist
string
Album artists joined with ", "; empty when unset.
art_url
string
mpris:artUrl as sent, e.g. an https:// image to fetch and cache; empty when unset.
artist
string
Artists joined with ", "; empty when unset.
can_go_next
boolean
MPRIS CanGoNext.
can_go_previous
boolean
MPRIS CanGoPrevious.
can_pause
boolean
MPRIS CanPause.
can_play
boolean
MPRIS CanPlay.
can_quit
boolean
MPRIS CanQuit on the root interface.
can_raise
boolean
MPRIS CanRaise on the root interface.
can_seek
boolean
MPRIS CanSeek.
desktop_entry
string
The player’s .desktop basename, e.g. "firefox", for app matching; empty when unset.
genre
string
Genres joined with ", "; empty when unset.
id
string
Bus-name suffix after org.mpris.MediaPlayer2., e.g. "spotify"; every action takes it.
identity
string
Display name, e.g. "Spotify"; empty if unanswered.
length?
integer
Track length in microseconds, or nil when unknown, as for a live stream.
loop_status?
LoopStatus
MPRIS loop mode; nil when the player does not report one.
maximum_rate
number
MPRIS maximum playback rate, or 0 when unavailable.
minimum_rate
number
MPRIS minimum playback rate, or 0 when unavailable.
pid?
integer
Process id of the bus name’s owner, which mantle.audio.apps[].pid matches exactly; nil when the bus refuses. A sandboxed app’s streams may report a pid from inside its sandbox.
play_state
PlayState
MPRIS PlaybackStatus; keeps the last value when a read fails, "stopped" if none.
playlists
PlaylistsState
One bounded page from the optional MPRIS Playlists interface.
position?
integer
Playback offset in microseconds as of position_updated_at, not polled while playing: add elapsed time. nil when unknown.
position_updated_at
integer
CLOCK_MONOTONIC microseconds when position was read: the clock of mantle.clock:now() in seconds, so mantle.clock:now() - position_updated_at / 1e6 is the age.
rate
number
MPRIS playback rate.
shuffle
boolean
MPRIS shuffle setting.
title
string
Track title; empty when unset, normal between tracks.
track_list
TrackListState
Nearby tracks from the optional MPRIS TrackList interface.
url
string
xesam:url as sent, e.g. a file:// path or an https:// page; empty when unset.
volume
number
MPRIS volume in percent, 100 when unreported. The protocol permits amplification above 100.
Session bus ListNames once, then NameOwnerChanged for org.mpris.MediaPlayer2.*. Skips playerctld and any player reporting CanControl = false
Pushes
On playback, metadata, control-property, TrackList or Playlists changes and on Seeked. A status change re-reads Position 100 ms later. Nothing polls
Seek
seek calls SetPosition with the cached mpris:trackid. A player without one gets a relative Seek from a live Position read
Controls
Read can_* before calling matching methods. Setters accept a finite nonnegative volume percent, positive finite rate within advertised limits, and "none", "track", or "playlist" loop status
Artwork
Uses existing local file:// paths. Remote artwork URLs are unsupported