RAGS - v1.11.0
    Preparing search index...

    Class MprisPlayer

    MPRIS Player

    Represents a single MPRIS-compatible media player on the session bus.

    Lifecycle:

    1. Construction - Connect to D-Bus player proxies
    2. Ready - Monitor playback state and metadata changes
    3. Disposal - Disconnect proxies and cleanup cover art cache

    closed - Emitted when player disappears from bus

    position - Emitted when position is set

    changed - Emitted when player state changes

    Hierarchy (View Summary)

    Implements

    Index

    Accessors

    • get bus_name(): string

      The full D-Bus bus name (e.g. "org.mpris.MediaPlayer2.spotify").

      Returns string

    • get can_go_next(): boolean

      Whether the player can advance to the next track.

      Returns boolean

    • get can_go_prev(): boolean

      Whether the player can go to the previous track.

      Returns boolean

    • get cover_path(): string

      Local file path of the cached cover art image.

      Returns string

    entry

    • get isDisposed(): boolean

      Check if service has been disposed

      Returns boolean

    • get loop_status(): LoopStatus | null

      Current loop status: "None", "Track", "Playlist", or null if unsupported.

      Returns LoopStatus | null

    • get play_back_status(): PlaybackStatus

      Current playback status: "Playing", "Paused", or "Stopped".

      Returns PlaybackStatus

    • get position(): number

      Current playback position in seconds (-1 if unavailable).

      Returns number

    • set position(time: number): void

      Sets the playback position in seconds.

      Parameters

      • time: number

      Returns void

    • get shuffle_status(): boolean | null

      Current shuffle status (true/false/null if unsupported).

      Returns boolean | null

    Constructors

    Methods

    • Creates a Binding for a property on this service.

      Type Parameters

      • Prop extends
            | "length"
            | "name"
            | "isDisposed"
            | "$signals"
            | "volume"
            | "bus_name"
            | "entry"
            | "identity"
            | "metadata"
            | "trackid"
            | "track_artists"
            | "track_title"
            | "track_album"
            | "track_cover_url"
            | "cover_path"
            | "play_back_status"
            | "can_go_next"
            | "can_go_prev"
            | "can_play"
            | "shuffle_status"
            | "loop_status"
            | "position"

      Parameters

      • prop: Prop

        The property to bind

      Returns Binding<MprisPlayer, Prop, MprisPlayer[Prop]>

      A Binding that can be used in widget constructors

      const label = Widget.Label({
      label: audio.bind('volume').as(v => `${Math.round(v * 100)}%`),
      });
    • Notifies listeners that a property changed and emits the 'changed' signal.

      Parameters

      • property: string

        The property name that changed

      Returns void

    • Connects a callback to a signal on this service.

      Parameters

      • signal: string = 'changed'

        The signal name (defaults to 'changed')

      • callback: (_: this, ...args: any[]) => void

        The callback to invoke when the signal is emitted

      Returns number

      The signal connection ID

    • Creates an incremental list binding that reuses existing widgets.

      Instead of recreating all widgets on every update, this method caches widgets by a key function and only creates new widgets for new items, destroying widgets for removed items.

      Type Parameters

      • Item
      • Prop extends
            | "length"
            | "name"
            | "isDisposed"
            | "$signals"
            | "volume"
            | "bus_name"
            | "entry"
            | "identity"
            | "metadata"
            | "trackid"
            | "track_artists"
            | "track_title"
            | "track_album"
            | "track_cover_url"
            | "cover_path"
            | "play_back_status"
            | "can_go_next"
            | "can_go_prev"
            | "can_play"
            | "shuffle_status"
            | "loop_status"
            | "position"

      Parameters

      • prop: Prop

        The property containing the item array

      • opts: {
            create: (item: Item) => Widget;
            key: (item: Item) => string | number;
            update?: (widget: Widget, item: Item) => void;
        }

        Key extractor, widget factory, and optional update callback

      Returns Binding<MprisPlayer, Prop, Widget[]>

      A Binding that produces an array of widgets

      const children = audio.diffBind('speakers', {
      key: (s) => s.name,
      create: (s) => Widget.Label({ label: s.description }),
      update: (w, s) => { w.label = s.description; },
      });
    • Clean up all tracked signal connections Call this in service-specific dispose implementations

      Returns void

    • Emits a signal, warning if the signal was not registered via Service.register.

      The warning is cheap (a Set lookup per emit) and helps catch typos and missing signal declarations that silently break .bind().

      Parameters

      • signal: string
      • ...args: any[]

      Returns void

    • Cycles loop status through None -> Track -> Playlist -> None.

      Returns void

    • Retry a DBus operation with exponential backoff

      Type Parameters

      • T

      Parameters

      • operation: () => Promise<T>
      • maxRetries: number = 3
      • baseDelay: number = 100

      Returns Promise<T>

    • Track a signal connection for automatic cleanup

      Parameters

      • emitter: Object

        The object the signal is connected to (defaults to this)

      • id: number

        The signal connection ID

      Returns void

    • Track a signal connection for automatic cleanup

      Parameters

      • id: number

        The signal connection ID

      Returns void

    • Updates a property value and emits a notify signal if the value changed.

      Performs a deep equality check via JSON serialization to avoid unnecessary notifications.

      Parameters

      • prop: string

        The property name in kebab-case

      • value: unknown

        The new value

      Returns void

    • Dynamically imports a built-in service by name.

      Type Parameters

      • S extends keyof Services

      Parameters

      • service: S

        The service name to import

      Returns Promise<Services[S]>

      The default export of the service module

      const Audio = await Service.import('audio');
      const Battery = await Service.import('battery');
    • Creates a GObject property specification.

      Parameters

      • name: string

        The property name in kebab-case

      • type: PspecType = 'jsobject'

        The property type (defaults to 'jsobject')

      • handle: PspecFlag = 'r'

        The access flag: 'r', 'w', or 'rw' (defaults to 'r')

      Returns ParamSpec<unknown>

      A GObject.ParamSpec

    • Registers a GObject subclass with signals and properties.

      Parameters

      • service: new (...args: any[]) => Object

        The class constructor to register

      • Optionalsignals: { [signal: string]: PspecType[] }

        Map of signal names to their parameter types

      • Optionalproperties: { [prop: string]: [type?: PspecType, handle?: PspecFlag] }

        Map of property names to [type, accessFlag] tuples

      Returns void