Documentation
¶
Index ¶
- type Bridge
- type Metadata
- type ModelAccessor
- type NextMsg
- type PauseMsg
- type PlayMsg
- type PlayPauseMsg
- type PlaybackStatus
- 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() (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() (PlaybackStatus, error)
- func (p PlayerAdapter) Position() (int64, error)
- func (p PlayerAdapter) Previous() error
- func (p PlayerAdapter) Rate() (float64, error)
- func (p PlayerAdapter) Seek(offset time.Duration) error
- func (p PlayerAdapter) SetPosition(trackId string, position time.Duration) 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.
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 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 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 time.Duration) error
OnSetPosition func(trackId string, position time.Duration) error
OnOpenUri func(uri string) error
OnPlaybackStatus func() (PlaybackStatus, error)
OnRate func() (float64, error)
OnSetRate func(rate float64) error
OnMetadata func() (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 supplies the org.mpris.MediaPlayer2.Player interface 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) Metadata ¶
func (p PlayerAdapter) Metadata() (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() (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) SetPosition ¶
func (p PlayerAdapter) SetPosition(trackId string, position time.Duration) 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 supplies the org.mpris.MediaPlayer2 interface 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 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, player PlayerAdapter) *Server
NewServer creates an MPRIS server for the app name with the given root and player adapters.
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 the playback position, in seconds.
func (*Server) StatusChanged ¶ added in v0.8.0
func (s *Server) StatusChanged()
StatusChanged tells MPRIS clients that the playback status changed.
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).