Documentation
¶
Index ¶
- type Bridge
- type Metadata
- type ModelAccessor
- type NextMsg
- type PauseMsg
- type PlayMsg
- type PlayPauseMsg
- type PlaybackStatus
- type PlayerActions
- type PreviousMsg
- type RootAdapter
- func (r RootAdapter) CanQuit() (bool, error)
- func (r RootAdapter) CanRaise() (bool, error)
- func (r RootAdapter) DesktopEntry() (string, error)
- func (r RootAdapter) HasTrackList() (bool, error)
- func (r RootAdapter) Identity() (string, error)
- func (r RootAdapter) Quit() error
- func (r RootAdapter) Raise() error
- func (r RootAdapter) SupportedMimeTypes() ([]string, error)
- func (r RootAdapter) SupportedUriSchemes() ([]string, error)
- type SeekAbsoluteMsg
- type SeekRelativeMsg
- type Server
- type SetRateMsg
- type SetVolumeMsg
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 (*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.
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 ¶
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
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 ¶
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).