mpris

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 8 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 pine's bubbletea program to the MPRIS D-Bus server.

func NewBridge

func NewBridge(program *tea.Program) *Bridge

NewBridge creates a new MPRIS bridge.

func (*Bridge) Bind

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

Bind wires the adapter closures to read from accessor and send messages via program.Send(). accessor is a function that returns the current ModelAccessor, called on each read. seekSeconds is the seek amount for Next/Previous (non-standard MPRIS).

func (*Bridge) EventHandler

func (b *Bridge) EventHandler() *events.EventHandler

EventHandler returns the MPRIS event handler for emitting property changes.

func (*Bridge) Start

func (b *Bridge) Start()

Start runs the D-Bus server in a goroutine.

func (*Bridge) Stop

func (b *Bridge) Stop() error

Stop shuts down the D-Bus server.

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
	QueueLength() int
}

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

type PlayPauseMsg

type PlayPauseMsg struct{}

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

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 types.Microseconds) error
	SetPosition func(trackId string, position types.Microseconds) error
	SetRate     func(rate float64) error
	SetVolume   func(vol int) error
}

PlayerActions defines the action callbacks for the PlayerAdapter.

type PlayerAdapter

type PlayerAdapter struct {
	OnNext           func() error
	OnPrevious       func() error
	OnPause          func() error
	OnPlayPause      func() error
	OnStop           func() error
	OnPlay           func() error
	OnSeek           func(offset types.Microseconds) error
	OnSetPosition    func(trackId string, position types.Microseconds) error
	OnOpenUri        func(uri string) error
	OnPlaybackStatus func() (types.PlaybackStatus, error)
	OnRate           func() (float64, error)
	OnSetRate        func(rate float64) error
	OnMetadata       func() (types.Metadata, error)
	OnVolume         func() (float64, error)
	OnSetVolume      func(vol float64) error
	OnPosition       func() (int64, error)
	OnMinimumRate    func() (float64, error)
	OnMaximumRate    func() (float64, error)
	OnCanGoNext      func() (bool, error)
	OnCanGoPrevious  func() (bool, error)
	OnCanPlay        func() (bool, error)
	OnCanPause       func() (bool, error)
	OnCanSeek        func() (bool, error)
	OnCanControl     func() (bool, error)
}

PlayerAdapter implements types.OrgMprisMediaPlayer2PlayerAdapter using closures. Each method field is a closure that reads from a ModelAccessor.

func NewPlayerAdapter

func NewPlayerAdapter(accessor func() ModelAccessor, actions PlayerActions) PlayerAdapter

NewPlayerAdapter creates a PlayerAdapter whose closures read from the accessor. accessor is a function that returns the current ModelAccessor, called on each read.

func (PlayerAdapter) CanControl

func (p PlayerAdapter) CanControl() (bool, error)

func (PlayerAdapter) CanGoNext

func (p PlayerAdapter) CanGoNext() (bool, error)

func (PlayerAdapter) CanGoPrevious

func (p PlayerAdapter) CanGoPrevious() (bool, error)

func (PlayerAdapter) CanPause

func (p PlayerAdapter) CanPause() (bool, error)

func (PlayerAdapter) CanPlay

func (p PlayerAdapter) CanPlay() (bool, error)

func (PlayerAdapter) CanSeek

func (p PlayerAdapter) CanSeek() (bool, error)

func (PlayerAdapter) MaximumRate

func (p PlayerAdapter) MaximumRate() (float64, error)

func (PlayerAdapter) Metadata

func (p PlayerAdapter) Metadata() (types.Metadata, error)

func (PlayerAdapter) MinimumRate

func (p PlayerAdapter) MinimumRate() (float64, error)

func (PlayerAdapter) Next

func (p PlayerAdapter) Next() error

func (PlayerAdapter) OpenUri

func (p PlayerAdapter) OpenUri(uri string) error

func (PlayerAdapter) Pause

func (p PlayerAdapter) Pause() error

func (PlayerAdapter) Play

func (p PlayerAdapter) Play() error

func (PlayerAdapter) PlayPause

func (p PlayerAdapter) PlayPause() error

func (PlayerAdapter) PlaybackStatus

func (p PlayerAdapter) PlaybackStatus() (types.PlaybackStatus, error)

func (PlayerAdapter) Position

func (p PlayerAdapter) Position() (int64, error)

func (PlayerAdapter) Previous

func (p PlayerAdapter) Previous() error

func (PlayerAdapter) Rate

func (p PlayerAdapter) Rate() (float64, error)

func (PlayerAdapter) Seek

func (p PlayerAdapter) Seek(offset types.Microseconds) error

func (PlayerAdapter) SetPosition

func (p PlayerAdapter) SetPosition(trackId string, position types.Microseconds) error

func (PlayerAdapter) SetRate

func (p PlayerAdapter) SetRate(rate float64) error

func (PlayerAdapter) SetVolume

func (p PlayerAdapter) SetVolume(vol float64) error

func (PlayerAdapter) Stop

func (p PlayerAdapter) Stop() error

func (PlayerAdapter) Volume

func (p PlayerAdapter) Volume() (float64, error)

type RootAdapter

type RootAdapter struct{}

RootAdapter implements types.OrgMprisMediaPlayer2Adapter with static values.

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 SeekMsg

type SeekMsg struct {
	Offset float64
}

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

type Server

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

Server wraps the MPRIS D-Bus server and event handler.

func NewServer

NewServer creates an MPRIS server with the given root and player adapters.

func (*Server) EventHandler

func (s *Server) EventHandler() *events.EventHandler

EventHandler returns the event handler for emitting property changes.

func (*Server) Listen

func (s *Server) Listen() error

Listen starts the D-Bus server. Blocks until Stop is called.

func (*Server) Stop

func (s *Server) Stop() error

Stop releases the D-Bus name and closes the connection.

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