Documentation
¶
Index ¶
- type Bridge
- type ModelAccessor
- type NextMsg
- type PauseMsg
- type PlayMsg
- type PlayPauseMsg
- type PlayerActions
- type PlayerAdapter
- func (p PlayerAdapter) CanControl() (bool, error)
- func (p PlayerAdapter) CanGoNext() (bool, error)
- func (p PlayerAdapter) CanGoPrevious() (bool, error)
- func (p PlayerAdapter) CanPause() (bool, error)
- func (p PlayerAdapter) CanPlay() (bool, error)
- func (p PlayerAdapter) CanSeek() (bool, error)
- func (p PlayerAdapter) MaximumRate() (float64, error)
- func (p PlayerAdapter) Metadata() (types.Metadata, error)
- func (p PlayerAdapter) MinimumRate() (float64, error)
- func (p PlayerAdapter) Next() error
- func (p PlayerAdapter) OpenUri(uri string) error
- func (p PlayerAdapter) Pause() error
- func (p PlayerAdapter) Play() error
- func (p PlayerAdapter) PlayPause() error
- func (p PlayerAdapter) PlaybackStatus() (types.PlaybackStatus, error)
- func (p PlayerAdapter) Position() (int64, error)
- func (p PlayerAdapter) Previous() error
- func (p PlayerAdapter) Rate() (float64, error)
- func (p PlayerAdapter) Seek(offset types.Microseconds) error
- func (p PlayerAdapter) SetPosition(trackId string, position types.Microseconds) error
- func (p PlayerAdapter) SetRate(rate float64) error
- func (p PlayerAdapter) SetVolume(vol float64) error
- func (p PlayerAdapter) Stop() error
- func (p PlayerAdapter) Volume() (float64, error)
- 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 SeekMsg
- 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 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. If skipSeekSeconds is more than 0, Next and Previous seek by that amount (non-standard MPRIS) and do not change the track.
func (*Bridge) EventHandler ¶
func (b *Bridge) EventHandler() *events.EventHandler
EventHandler returns the MPRIS event handler for emitting property changes.
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
QueueLength() int
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 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(name string, accessor func() ModelAccessor, actions PlayerActions) PlayerAdapter
NewPlayerAdapter creates a PlayerAdapter whose closures read from the accessor. name is the app name used in track object paths. 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) 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 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 implements types.OrgMprisMediaPlayer2Adapter with static values. Name is the app name that MPRIS clients see.
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 SeekMsg ¶
type SeekMsg struct {
Offset float64
}
SeekMsg is sent when MPRIS requests a seek by offset (in seconds).
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 wraps the MPRIS D-Bus server and event handler.
func NewServer ¶
func NewServer(name string, root types.OrgMprisMediaPlayer2Adapter, player types.OrgMprisMediaPlayer2PlayerAdapter) *Server
NewServer creates an MPRIS server for the app name 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.
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).