MprisPlayer: QtObject [uncreatable]
import Quickshell.Services.Mpris
A media player exposed over MPRIS. More
Properties
- canControl: bool
- canGoNext: bool
- canGoPrevious: bool
- canPause: bool
- canPlay: bool
- canQuit: bool
- canRaise: bool
- canSeek: bool
- canSetFullscreen: bool
- canTogglePlaying: bool
- desktopEntry: string
- fullscreen: bool
- identity: string
- length: real
- lengthSupported: bool
- loopState: MprisLoopState
- loopSupported: bool
- maxRate: real
- metadata: unknown
- minRate: real
- playbackState: MprisPlaybackState
- position: real
- positionSupported: bool
- rate: real
- shuffle: bool
- shuffleSupported: bool
- supportedMimeTypes: list<string>
- supportedUriSchemes: list<string>
- trackAlbum: string
- trackAlbumArtist: string
- trackArtUrl: string
- trackArtists: list<string>
- trackTitle: string
- uniqueId: int
- volume: real
- volumeSupported: bool
Functions
- void next()
- void openUri(uri: string)
- void pause()
- void play()
- void previous()
- void quit()
- void raise()
- void seek(offset: real)
- void stop()
- void togglePlaying()
Detailed Description
A media player exposed over MPRIS.
canXyz
and xyzSupported
properties if available.
Property Details
canControl: bool
No details provided.
canGoNext: bool
No details provided.
canGoPrevious: bool
No details provided.
canPause: bool
No details provided.
canPlay: bool
No details provided.
canQuit: bool
No details provided.
canRaise: bool
No details provided.
canSeek: bool
No details provided.
canSetFullscreen: bool
No details provided.
canTogglePlaying: bool
No details provided.
desktopEntry: string
The name of the desktop entry for the media player, or an empty string if not provided.
fullscreen: bool
If the player is currently shown in fullscreen.
May only be written to if canSetFullscreen is true.
identity: string
The human readable name of the media player.
length: real
The length of the playing track, as seconds, with millisecond precision, or the value of position if lengthSupported is false.
lengthSupported: bool
No details provided.
loopState: MprisLoopState
The loop state of the media player, or None
if loopSupported is false.
May only be written to if canControl and loopSupported are true.
loopSupported: bool
No details provided.
maxRate: real
No details provided.
metadata: unknown
Metadata of the current track.
A map of common properties is available here. Do not count on any of them actually being present.
Note that the trackTitle, trackAlbum, trackAlbumArtist, trackArtists and trackArtUrl properties have extra logic to guard against bad players sending weird metadata, and should be used over grabbing the properties directly from the metadata.
minRate: real
No details provided.
playbackState: MprisPlaybackState
The playback state of the media player.
- If canPlay is false, you cannot assign the
Playing
state. - If canPause is false, you cannot assign the
Paused
state. - If canControl is false, you cannot assign the
Stopped
state. (or any of the others, though their repsective properties will also be false)
position: real
The current position in the playing track, as seconds, with millisecond precision,
or 0
if positionSupported is false.
May only be written to if canSeek and positionSupported are true.
To avoid excessive property updates wasting CPU while position
is not
actively monitored, position
usually will not update reactively, unless a nonlinear
change in position occurs, however reading it will always return the current position.
If you want to actively monitor the position, the simplest way it to emit the [signal] positionChanged() signal manually for the duration you are monitoring it, Using a FrameAnimation if you need the value to update smoothly, such as on a slider, or a Timer if not, as shown below.
FrameAnimation {
// only emit the signal when the position is actually changing.
running: player.playbackState == MprisPlaybackState.Playing
// emit the positionChanged signal every frame.
onTriggered: player.positionChanged()
}
Timer {
// only emit the signal when the position is actually changing.
running: player.playbackState == MprisPlaybackState.Playing
// Make sure the position updates at least once per second.
interval: 1000
repeat: true
// emit the positionChanged signal every second.
onTriggered: player.positionChanged()
}
positionSupported: bool
No details provided.
rate: real
The speed the song is playing at, as a multiplier.
Only values between minRate and maxRate (inclusive) may be written to the property.
Additionally, It is recommended that you only write common values such as 0.25
, 0.5
, 1.0
, 2.0
to the property, as media players are free to ignore the value, and are more likely to
accept common ones.
shuffle: bool
If the play queue is currently being shuffled, or false if shuffleSupported is false.
May only be written if canControl and shuffleSupported are true.
shuffleSupported: bool
No details provided.
Mime types supported by openUri().
Uri schemes supported by openUri().
trackAlbum: string
The current track’s album, or “Unknown Album” if none was provided.
trackAlbumArtist: string
The current track’s album artist, or “Unknown Artist” if none was provided.
trackArtUrl: string
The current track’s art url, or ""
if none was provided.
The current track’s artists, or an empty list if none were provided.
trackTitle: string
The title of the current track, or “Unknown Track” if none was provided.
uniqueId: int
An opaque identifier for the current track unique within the current player.
mpris:trackid
as that is sometimes missing or nonunique
in some players.
volume: real
The volume of the playing track from 0.0 to 1.0, or 1.0 if volumeSupported is false.
May only be written to if canControl and volumeSupported are true.
volumeSupported: bool
No details provided.
Function Details
void next()
Play the next song.
May only be called if canGoNext is true.
Open the given URI in the media player.
Many players will silently ignore this, especially if the uri does not match supportedUriSchemes and supportedMimeTypes.
void pause()
Equivalent to setting playbackState to Paused
.
void play()
Equivalent to setting playbackState to Playing
.
void previous()
Play the previous song, or go back to the beginning of the current one.
May only be called if canGoPrevious is true.
void quit()
Quit the media player.
May only be called if canQuit is true.
void raise()
Bring the media player to the front of the window stack.
May only be called if canRaise is true.
Change position
by an offset.
Even if positionSupported is false and you cannot set position
,
this function may work.
May only be called if canSeek is true.
void stop()
Equivalent to setting playbackState to Stopped
.
void togglePlaying()
Equivalent to calling play() if not playing or pause() if playing.
May only be called if canTogglePlaying is true, which is equivalent to canPlay or canPause() depending on the current playback state.