mpris

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bridge

type Bridge struct {
	// contains filtered or unexported fields
}

Bridge connects the app's bubbletea program to the MPRIS D-Bus server.

func NewBridge

func NewBridge(program *tea.Program, name string) *Bridge

NewBridge creates a new MPRIS bridge. name is the app name that MPRIS clients see.

func (*Bridge) Bind

func (b *Bridge) Bind(accessor func() ModelAccessor, skipSeekSeconds float64)

Bind creates the MPRIS server. Its properties read from accessor, and its methods send messages via program.Send(). accessor is a function that returns the current ModelAccessor, called on each read. If skipSeekSeconds is more than 0, Next and Previous seek by that amount (non-standard MPRIS) and do not change the track.

func (*Bridge) Server added in v0.8.0

func (b *Bridge) Server() *Server

Server returns the MPRIS server. It is nil before Bind.

func (*Bridge) Start

func (b *Bridge) Start()

Start runs the D-Bus server in a goroutine and starts the message dispatcher loop.

func (*Bridge) Stop

func (b *Bridge) Stop() error

Stop shuts down the D-Bus server and terminates the dispatcher loop.

type Metadata added in v0.8.0

type Metadata struct {
	TrackID dbus.ObjectPath
	Length  time.Duration
	Title   string
	Artist  []string
}

Metadata is the metadata of the current track.

type ModelAccessor

type ModelAccessor interface {
	IsPlaying() bool
	IsPaused() bool
	HasActiveItem() bool
	CurrentTitle() string
	CurrentAuthors() []string
	CurrentItemID() string
	PlayerPosition() float64
	PlayerDuration() float64
	PlayerVolume() int
	PlayerSpeed() float64
	PlayerMinimumRate() float64
	PlayerMaximumRate() float64
	CanSeek() bool
	CanGoNext() bool
	CanGoPrevious() bool
}

ModelAccessor provides read-only access to the app's playback state.

type NextMsg added in v0.6.0

type NextMsg struct{}

NextMsg is sent when MPRIS requests skipping to the next track.

type PauseMsg added in v0.6.0

type PauseMsg struct{}

PauseMsg is sent when MPRIS requests playback to pause.

type PlayMsg added in v0.6.0

type PlayMsg struct{}

PlayMsg is sent when MPRIS requests playback to resume.

type PlayPauseMsg

type PlayPauseMsg struct{}

PlayPauseMsg is sent when MPRIS requests a play/pause toggle.

type PlaybackStatus added in v0.8.0

type PlaybackStatus string

PlaybackStatus is a value of the MPRIS PlaybackStatus property.

const (
	StatusPlaying PlaybackStatus = "Playing"
	StatusPaused  PlaybackStatus = "Paused"
	StatusStopped PlaybackStatus = "Stopped"
)

type PlayerActions

type PlayerActions struct {
	Next        func() error
	Previous    func() error
	Pause       func() error
	PlayPause   func() error
	Stop        func() error
	Play        func() error
	Seek        func(offset time.Duration) error
	SetPosition func(trackId string, position time.Duration) error
	SetRate     func(rate float64) error
	// SetVolume gets the MPRIS volume, where 1.0 is the app volume 100.
	SetVolume func(volume float64) error
}

PlayerActions defines the callbacks of the methods and the writable properties of the org.mpris.MediaPlayer2.Player interface.

type PreviousMsg added in v0.6.0

type PreviousMsg struct{}

PreviousMsg is sent when MPRIS requests skipping to the previous track.

type RootAdapter

type RootAdapter struct {
	Name string
}

RootAdapter supplies the org.mpris.MediaPlayer2 interface with static values. Name is the app name that MPRIS clients see. Quit and Raise do nothing, so CanQuit and CanRaise are false.

func (RootAdapter) CanQuit

func (r RootAdapter) CanQuit() (bool, error)

func (RootAdapter) CanRaise

func (r RootAdapter) CanRaise() (bool, error)

func (RootAdapter) DesktopEntry

func (r RootAdapter) DesktopEntry() (string, error)

func (RootAdapter) HasTrackList

func (r RootAdapter) HasTrackList() (bool, error)

func (RootAdapter) Identity

func (r RootAdapter) Identity() (string, error)

func (RootAdapter) Quit

func (r RootAdapter) Quit() error

func (RootAdapter) Raise

func (r RootAdapter) Raise() error

func (RootAdapter) SupportedMimeTypes

func (r RootAdapter) SupportedMimeTypes() ([]string, error)

func (RootAdapter) SupportedUriSchemes

func (r RootAdapter) SupportedUriSchemes() ([]string, error)

type SeekAbsoluteMsg added in v0.6.0

type SeekAbsoluteMsg struct {
	PositionSeconds float64
}

SeekAbsoluteMsg is sent when MPRIS requests setting position to an absolute timestamp (in seconds) for the current track.

type SeekRelativeMsg added in v0.6.0

type SeekRelativeMsg struct {
	OffsetSeconds float64
}

SeekRelativeMsg is sent when MPRIS requests a relative seek by offset (in seconds).

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is an MPRIS media player on the D-Bus session bus. It has the org.mpris.MediaPlayer2 and org.mpris.MediaPlayer2.Player interfaces.

func NewServer

func NewServer(name string, root RootAdapter, accessor func() ModelAccessor, actions PlayerActions) *Server

NewServer creates an MPRIS server for the app name. The player properties read the app state from accessor on each request, and the player methods and the writable properties call actions.

func (*Server) Listen

func (s *Server) Listen() error

Listen connects to the session bus and answers MPRIS requests. It blocks until Stop is called or the connection closes.

func (*Server) MetadataChanged added in v0.8.0

func (s *Server) MetadataChanged()

MetadataChanged tells MPRIS clients that the track metadata changed.

func (*Server) PlaybackChanged added in v0.8.0

func (s *Server) PlaybackChanged()

PlaybackChanged tells MPRIS clients that the playback state, the rate, or the track changed.

func (*Server) Seeked added in v0.8.0

func (s *Server) Seeked(positionSeconds float64)

Seeked tells MPRIS clients that the position changed in a way that the rate does not explain, for example by a seek. positionSeconds is the new position. During playback, a client computes the position from the rate.

func (*Server) StatusChanged added in v0.8.0

func (s *Server) StatusChanged()

StatusChanged tells MPRIS clients that the playback status changed, and with it CanPlay, CanPause, CanGoNext, and CanGoPrevious.

func (*Server) Stop

func (s *Server) Stop() error

Stop closes the connection to the session bus. The bus then releases the name.

func (*Server) VolumeChanged added in v0.8.0

func (s *Server) VolumeChanged()

VolumeChanged tells MPRIS clients that the volume changed.

type SetRateMsg

type SetRateMsg struct {
	Rate float64
}

SetRateMsg is sent when MPRIS sets the playback rate.

type SetVolumeMsg

type SetVolumeMsg struct {
	Volume int
}

SetVolumeMsg is sent when MPRIS sets the volume (0-150 scale).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL