MPRIS (media)#

class ignis.services.mpris.MprisService(*args: Any, **kwargs: Any)#

Service for getting and controlling media players using the MPRIS interface (e.g., Spotify, Firefox/Chromium with playing media).

Dependencies:
  • python-requests

Signals:
Properties:
  • players (list[Application], read-only): A list of currently active players.

Example usage:

from ignis.service import MprisService

mpris = MprisService.get_default()

mpris.connect("player_added", lambda x, player: print(player.desktop_entry, player.title))
class ignis.services.mpris.MprisPlayer(*args: Any, **kwargs: Any)#

A media player object.

Signals:
  • "closed" (): Emitted when a player has been closed or removed.

Properties:
  • can_control (bool, read-only): Whether the player can be controlled.

  • can_go_next (bool, read-only): Whether the player can go to the next track.

  • can_go_previous (bool, read-only): Whether the player can go to the previous track.

  • can_pause (bool, read-only): Whether the player can pause.

  • can_play (bool, read-only): Whether the player can play.

  • can_seek (bool, read-only): Whether the player can seek (change position on track in seconds).

  • loop_status (str, read-only): Loop status.

  • metadata (dict, read-only): Dictionary containing metadata. You typically shouldn't use this property.

  • track_id (str, read-only): Track ID.

  • length (int, read-only): Length of media. Returns -1 if not supported by player.

  • art_url (str | None, read-only): Path to cached art image of media.

  • album (str, read-only): Album name.

  • artist (str, read-only): Artist name.

  • title (str, read-only): Current title.

  • url (str, read-only): URL address to the media.

  • playback_status (str, read-only): Playback status. Can be "Playing" or "Paused".

  • position (position, read-write): Current position in the track, in seconds.

  • shuffle (bool, read-only): Shuffle status (honestly idk what is that).

  • volume (float, read-only): Player volume.

  • identity (bool, read-only): Name of the player (e.g. "Spotify", "firefox").

  • desktop_entry (bool, read-only): .desktop file of the player.

next() None#

Go to the next track.

previous() None#

Go to the previous track.

pause() None#

Pause playback.

play() None#

Start playback.

play_pause() None#

Toggle between playing and pausing.

stop() None#

Stop playback and remove the MPRIS interface if supported by the player.

seek(offset: int) None#

Seek to a specific position in the track. Positive values move forward, and negative values move backward. The offset is in milliseconds.