Documentation
¶
Index ¶
- Variables
- func ExtractAlbum(meta map[string]dbus.Variant) string
- func ExtractArtist(meta map[string]dbus.Variant) string
- func ExtractTitle(meta map[string]dbus.Variant) string
- func ExtractTrackID(meta map[string]dbus.Variant) string
- func StringInstanceCompare(name, instance string) int
- type FormatError
- type Formatter
- type InvalidCommandError
- type LoopStatus
- type PlaybackStatus
- type Player
- func (p *Player) CanControl() (bool, error)
- func (p *Player) CanGoNext() (bool, error)
- func (p *Player) CanGoPrevious() (bool, error)
- func (p *Player) CanPause() (bool, error)
- func (p *Player) CanPlay() (bool, error)
- func (p *Player) CanSeek() (bool, error)
- func (p *Player) Close()
- func (p *Player) Closed() bool
- func (p *Player) Disappeared() bool
- func (p *Player) GetAlbum() (string, error)
- func (p *Player) GetArtist() (string, error)
- func (p *Player) GetTitle() (string, error)
- func (p *Player) GetTrackID() (string, error)
- func (p *Player) Instance() string
- func (p *Player) LoopStatus() (LoopStatus, error)
- func (p *Player) Metadata() (map[string]dbus.Variant, error)
- func (p *Player) Name() string
- func (p *Player) Next() error
- func (p *Player) OpenURI(uri string) error
- func (p *Player) OpenUri(uri string) error
- func (p *Player) Pause() error
- func (p *Player) Play() error
- func (p *Player) PlayPause() error
- func (p *Player) PlaybackStatus() (PlaybackStatus, error)
- func (p *Player) Position() (int64, error)
- func (p *Player) Previous() error
- func (p *Player) Seek(offset int64) error
- func (p *Player) SetLoopStatus(status LoopStatus) error
- func (p *Player) SetPosition(trackID string, position int64) error
- func (p *Player) SetShuffle(enabled bool) error
- func (p *Player) SetVolume(volume float64) error
- func (p *Player) Shuffle() (bool, error)
- func (p *Player) Source() Source
- func (p *Player) Stop() error
- func (p *Player) Volume() (float64, error)
- func (p *Player) WaitForDisappear(timeout time.Duration) bool
- type PlayerManager
- func (m *PlayerManager) FilterPlayerNames(allow []string, ignore []string) []*PlayerName
- func (m *PlayerManager) HandleNameOwnerChanged(busName, oldOwner, newOwner string, source Source)
- func (m *PlayerManager) ManagePlayer(player *Player)
- func (m *PlayerManager) MovePlayerToTop(player *Player)
- func (m *PlayerManager) PlayerNames() []*PlayerName
- func (m *PlayerManager) Players() []*Player
- func (m *PlayerManager) Refresh() error
- func (m *PlayerManager) SortPlayersByActivity(weight func(*Player) int)
- func (m *PlayerManager) Source() Source
- type PlayerName
- type Source
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPlayerNotFound indicates that no player matching the selector could be found. ErrPlayerNotFound = errors.New("player not found") )
Functions ¶
func ExtractAlbum ¶ added in v0.0.3
ExtractAlbum returns the xesam:album string from a metadata map.
func ExtractArtist ¶ added in v0.0.3
ExtractArtist returns a best-effort artist string from a metadata map.
func ExtractTitle ¶ added in v0.0.3
ExtractTitle returns the xesam:title string from a metadata map.
func ExtractTrackID ¶ added in v0.0.3
ExtractTrackID returns the mpris:trackid string from a metadata map.
func StringInstanceCompare ¶
StringInstanceCompare compares a player instance string with a matcher string. Supports "%any" matcher and partial instance matching (e.g., "vlc" matches "vlc.instanceXXXX").
Types ¶
type FormatError ¶
type FormatError struct {
Message string
}
FormatError reports a formatter parse or rendering error.
func (FormatError) Error ¶
func (e FormatError) Error() string
Error implements the error interface.
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
Formatter expands text/template expressions using a string context.
func NewFormatter ¶
NewFormatter constructs a formatter for a template string.
func (*Formatter) ContainsKey ¶
ContainsKey reports whether the template references the provided key.
type InvalidCommandError ¶
type InvalidCommandError struct {
Command string
}
InvalidCommandError indicates that a command is not supported by the current player or context.
func (InvalidCommandError) Error ¶
func (e InvalidCommandError) Error() string
Error implements the error interface.
type LoopStatus ¶
type LoopStatus int
LoopStatus represents the loop status for a PlayerctlPlayer.
const ( // LoopStatusNone means playback stops when no tracks remain. LoopStatusNone LoopStatus = iota // LoopStatusTrack means the current track repeats. LoopStatusTrack // LoopStatusPlaylist means the active playlist repeats. LoopStatusPlaylist )
func ParseLoopStatus ¶
func ParseLoopStatus(statusStr string) (LoopStatus, bool)
ParseLoopStatus parses a string into a LoopStatus. Returns the parsed status and a boolean indicating success.
func (LoopStatus) String ¶
func (s LoopStatus) String() string
String returns the string representation of the LoopStatus.
type PlaybackStatus ¶
type PlaybackStatus int
PlaybackStatus represents the playback status for a Player.
const ( // PlaybackStatusPlaying indicates active playback. PlaybackStatusPlaying PlaybackStatus = iota // PlaybackStatusPaused indicates playback is paused. PlaybackStatusPaused // PlaybackStatusStopped indicates playback has stopped. PlaybackStatusStopped )
func ParsePlaybackStatus ¶
func ParsePlaybackStatus(statusStr string) (PlaybackStatus, bool)
ParsePlaybackStatus parses a string into a PlaybackStatus. Returns the parsed status and a boolean indicating success.
func (PlaybackStatus) String ¶
func (s PlaybackStatus) String() string
String returns the string representation of the PlaybackStatus.
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player models a single controllable media player connection.
func NewPlayerFromName ¶
func NewPlayerFromName(name *PlayerName) (*Player, error)
NewPlayerFromName creates a Player from a fully qualified PlayerName.
func (*Player) CanControl ¶
CanControl reports whether the player supports control actions.
func (*Player) CanGoPrevious ¶
func (*Player) Close ¶
func (p *Player) Close()
Close marks the Player as closed and releases locally held state.
func (*Player) Disappeared ¶
Disappeared reports whether the player service vanished from D-Bus.
func (*Player) GetTrackID ¶
GetTrackID returns mpris:trackid metadata.
func (*Player) LoopStatus ¶
func (p *Player) LoopStatus() (LoopStatus, error)
LoopStatus returns the player's loop status.
func (*Player) PlaybackStatus ¶
func (p *Player) PlaybackStatus() (PlaybackStatus, error)
PlaybackStatus returns the player's current playback status.
func (*Player) SetLoopStatus ¶
func (p *Player) SetLoopStatus(status LoopStatus) error
SetLoopStatus sets loop mode.
func (*Player) SetShuffle ¶
SetShuffle toggles shuffle mode.
type PlayerManager ¶
type PlayerManager struct {
// contains filtered or unexported fields
}
PlayerManager tracks discovered players and managed player instances.
func NewPlayerManager ¶
func NewPlayerManager(source Source) (*PlayerManager, error)
NewPlayerManager constructs a manager for a given bus source.
func (*PlayerManager) FilterPlayerNames ¶
func (m *PlayerManager) FilterPlayerNames(allow []string, ignore []string) []*PlayerName
FilterPlayerNames applies --player/%any style selection and ignore lists.
func (*PlayerManager) HandleNameOwnerChanged ¶
func (m *PlayerManager) HandleNameOwnerChanged(busName, oldOwner, newOwner string, source Source)
HandleNameOwnerChanged updates manager state based on NameOwnerChanged signal args.
func (*PlayerManager) ManagePlayer ¶
func (m *PlayerManager) ManagePlayer(player *Player)
ManagePlayer adds a connected player to the managed list.
func (*PlayerManager) MovePlayerToTop ¶
func (m *PlayerManager) MovePlayerToTop(player *Player)
MovePlayerToTop moves a managed player to the front, preserving order otherwise.
func (*PlayerManager) PlayerNames ¶
func (m *PlayerManager) PlayerNames() []*PlayerName
PlayerNames returns a copy of discovered player names.
func (*PlayerManager) Players ¶
func (m *PlayerManager) Players() []*Player
Players returns a copy of managed players.
func (*PlayerManager) Refresh ¶
func (m *PlayerManager) Refresh() error
Refresh performs discovery via org.freedesktop.DBus ListNames.
func (*PlayerManager) SortPlayersByActivity ¶
func (m *PlayerManager) SortPlayersByActivity(weight func(*Player) int)
SortPlayersByActivity applies stable ordering callback. Lower weight ranks first.
func (*PlayerManager) Source ¶
func (m *PlayerManager) Source() Source
Source returns manager bus source.
type PlayerName ¶
PlayerName contains connection information that fully qualifies a potential connection to a player.
func NewPlayerName ¶
func NewPlayerName(instance string, source Source) *PlayerName
NewPlayerName creates a new PlayerName instance. instance is the complete name and instance of the player.
func (*PlayerName) Compare ¶
func (p *PlayerName) Compare(other *PlayerName) int
Compare compares two PlayerNames. It returns 0 if they are equal, otherwise non-zero.
func (*PlayerName) InstanceCompare ¶
func (p *PlayerName) InstanceCompare(other *PlayerName) int
InstanceCompare compares a PlayerName to another PlayerName treating the second as an instance matcher. Returns 0 if they match, otherwise non-zero.