Documentation
¶
Index ¶
- Constants
- Variables
- func List(conn *dbus.Conn) ([]string, error)
- func OnSignal(conn *dbus.Conn, ch chan<- *dbus.Signal) error
- type BaseHandler
- type Client
- func (i *Client) CanControl() (bool, error)
- func (i *Client) CanEditTracks() (bool, error)
- func (i *Client) CanGoNext() (bool, error)
- func (i *Client) CanGoPrevious() (bool, error)
- func (i *Client) CanPause() (bool, error)
- func (i *Client) CanPlay() (bool, error)
- func (i *Client) CanQuit() (bool, error)
- func (i *Client) CanRaise() (bool, error)
- func (i *Client) CanSeek() (bool, error)
- func (i *Client) CanSetFullscreen() (bool, error)
- func (i *Client) GetAlbum() (string, error)
- func (i *Client) GetArtURL() (string, error)
- func (i *Client) GetArtist() ([]string, error)
- func (i *Client) GetBaseProperty(property string) (dbus.Variant, error)
- func (i *Client) GetDesktopEntry() (string, error)
- func (i *Client) GetFullscreen() (bool, error)
- func (i *Client) GetIdentity() (string, error)
- func (i *Client) GetLength() (time.Duration, error)
- func (i *Client) GetLoopStatus() (LoopStatus, error)
- func (i *Client) GetMaximumRate() (float64, error)
- func (i *Client) GetMetadata() (Metadata, error)
- func (i *Client) GetMinimumRate() (float64, error)
- func (i *Client) GetName() string
- func (i *Client) GetPlaybackStatus() (PlaybackStatus, error)
- func (i *Client) GetPlayerProperty(property string) (dbus.Variant, error)
- func (i *Client) GetPlaylistsProperty(property string) (dbus.Variant, error)
- func (i *Client) GetPosition() (time.Duration, error)
- func (i *Client) GetProperty(iface, property string) (dbus.Variant, error)
- func (i *Client) GetRate() (float64, error)
- func (i *Client) GetShuffle() (bool, error)
- func (i *Client) GetSupportedURISchemes() ([]string, error)
- func (i *Client) GetTitle() (string, error)
- func (i *Client) GetTrackID() (dbus.ObjectPath, error)
- func (i *Client) GetTrackListProperty(property string) (dbus.Variant, error)
- func (i *Client) GetURL() (string, error)
- func (i *Client) GetVolume() (float64, error)
- func (i *Client) HasTrackList() (bool, error)
- func (i *Client) Next() error
- func (i *Client) OnSeeked(ctx context.Context, position chan<- time.Duration) error
- func (i *Client) OpenURI(uri string) error
- func (i *Client) Pause() error
- func (i *Client) Play() error
- func (i *Client) PlayPause() error
- func (i *Client) Previous() error
- func (i *Client) Quit() error
- func (i *Client) Raise() error
- func (i *Client) Seek(offset time.Duration) error
- func (i *Client) SetBaseProperty(property string, value any) error
- func (i *Client) SetFullscreen(fullscreen bool) error
- func (i *Client) SetLoopStatus(loopStatus LoopStatus) error
- func (i *Client) SetPlayerProperty(property string, value any) error
- func (i *Client) SetPlaylistsProperty(property string, value any) error
- func (i *Client) SetPosition(position time.Duration) error
- func (i *Client) SetProperty(iface, property string, value any) error
- func (i *Client) SetRate(rate float64) error
- func (i *Client) SetShuffle(value bool) error
- func (i *Client) SetTrackListProperty(property string, value any) error
- func (i *Client) SetTrackPosition(trackID *dbus.ObjectPath, position time.Duration) error
- func (i *Client) SetVolume(volume float64) error
- func (i *Client) Stop() error
- func (i *Client) SupportedMimeTypes() ([]string, error)
- type LoopStatus
- type Metadata
- type NoOpBaseHandler
- type NoOpPlayerHandler
- func (NoOpPlayerHandler) Next() error
- func (NoOpPlayerHandler) OpenURI(string) error
- func (NoOpPlayerHandler) Pause() error
- func (NoOpPlayerHandler) Play() error
- func (NoOpPlayerHandler) PlayPause() error
- func (NoOpPlayerHandler) Previous() error
- func (NoOpPlayerHandler) Seek(time.Duration) error
- func (NoOpPlayerHandler) SetPosition(dbus.ObjectPath, time.Duration) error
- func (NoOpPlayerHandler) Stop() error
- type NoOpPropertySetter
- type PlaybackStatus
- type PlayerHandler
- type Properties
- type PropertiesManager
- type PropertySetter
- type Server
- func (s *Server) Close() error
- func (s *Server) Listen(ctx context.Context) error
- func (s *Server) RegisterBaseHandler(handler BaseHandler) error
- func (s *Server) RegisterPlayerHandler(handler PlayerHandler) error
- func (s *Server) RegisterPropertiesManager(pm *PropertiesManager, setter PropertySetter) error
Constants ¶
const ( // DBusObjectPath is the root object path for MPRIS-compatible media // players. All MPRIS interfaces are exposed under this path on the D-Bus. DBusObjectPath = "/org/mpris/MediaPlayer2" // PropertiesChangedSignal is the D-Bus signal name emitted when a property // changes on an MPRIS interface. PropertiesChangedSignal = "org.freedesktop.DBus.Properties.PropertiesChanged" // BaseInterface is the main MPRIS interface that provides general // information and capabilities about the media player instance. BaseInterface = "org.mpris.MediaPlayer2" // PlayerInterface defines methods and properties for controlling playback, // such as play, pause, seek, and retrieving track metadata. PlayerInterface = "org.mpris.MediaPlayer2.Player" // TrackListInterface provides access to the list of tracks managed by the // player, allowing navigation, retrieval, and management of track items. TrackListInterface = "org.mpris.MediaPlayer2.TrackList" // PlaylistsInterface defines the MPRIS interface for managing and // activating playlists exposed by the player. PlaylistsInterface = "org.mpris.MediaPlayer2.Playlists" // PlaylistsInterface defines the MPRIS properties. DBusPropertyInterface = "org.freedesktop.DBus.Properties" // GetPropertyMethod is the standard D-Bus method used to retrieve the value // of a property from an interface that implements // org.freedesktop.DBus.Properties. GetPropertyMethod = "org.freedesktop.DBus.Properties.Get" // SetPropertyMethod is the standard D-Bus method used to change the value // of a writable property on an interface that implements // org.freedesktop.DBus.Properties. SetPropertyMethod = "org.freedesktop.DBus.Properties.Set" )
const ( // KeyAlbum is the album name. KeyAlbum = "xesam:album" // KeyAlbumArtist is the album artist(s). KeyAlbumArtist = "xesam:albumArtist" // KeyArtist is the track artist(s). KeyArtist = "xesam:artist" // KeyAsText is the text/lyrics of the track. KeyAsText = "xesam:asText" // KeyAudioBPM is the speed of the music in beats per minute. KeyAudioBPM = "xesam:audioBPM" // KeyAutoRating is an automatically generated rating (0.0 to 1.0). KeyAutoRating = "xesam:autoRating" // KeyComment is a social comment about the track. KeyComment = "xesam:comment" // KeyComposer is the track composer(s). KeyComposer = "xesam:composer" // KeyContentCreated is the date/time the content was created. KeyContentCreated = "xesam:contentCreated" // KeyDiscNumber is the disc number on the album. KeyDiscNumber = "xesam:discNumber" // KeyFirstUsed is the date/time the track was first played. KeyFirstUsed = "xesam:firstUsed" // KeyGenre is the genre(s) of the track. KeyGenre = "xesam:genre" // KeyLastUsed is the date/time the track was last played by any user. KeyLastUsed = "xesam:lastUsed" // KeyLastUsedByMe is the date/time the track was last played by the current // user. KeyLastUsedByMe = "xesam:lastUsedByMe" // KeyLyricist is the person who wrote the lyrics for the track. KeyLyricist = "xesam:lyricist" // KeyTitle is the item title. KeyTitle = "xesam:title" // KeyTrackNumber is the track number on the album. KeyTrackNumber = "xesam:trackNumber" // KeyURL is the location of the media file. KeyURL = "xesam:url" // KeyUseCount is the number of times the track has been played. KeyUseCount = "xesam:useCount" // KeyUserRating is the user's rating of the track (0.0 to 1.0). KeyUserRating = "xesam:userRating" // KeyTrackID is a unique identity for the track within the context of the playlist. KeyTrackID = "mpris:trackid" // KeyLength is the duration of the track in microseconds. KeyLength = "mpris:length" // KeyArtURL is a URI of some album art designed to represent the track/album. KeyArtURL = "mpris:artUrl" )
Variables ¶
Functions ¶
Types ¶
type BaseHandler ¶
BaseHandler defines the methods for the org.mpris.MediaPlayer2 interface.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a mpris player.
func (*Client) CanControl ¶
CanControl returns whether the player can be controlled.
func (*Client) CanEditTracks ¶
CanEditTracks returns if player can edit track list.
func (*Client) CanGoPrevious ¶
CanGoPrevious returns whether the player can skip to the previous track.
func (*Client) CanSetFullscreen ¶
CanSetFullscreen returns whether the player allows changing fullscreen state.
func (*Client) GetBaseProperty ¶
GetBaseProperty returns the prop from the base interface.
func (*Client) GetDesktopEntry ¶
GetDesktopEntry returns the desktop entry name of the player.
func (*Client) GetFullscreen ¶
GetFullscreen returns whether the player is in fullscreen mode.
func (*Client) GetIdentity ¶
GetIdentity returns the player identity.
func (*Client) GetLoopStatus ¶
func (i *Client) GetLoopStatus() (LoopStatus, error)
GetLoopStatus returns the current loop status.
func (*Client) GetMaximumRate ¶
GetMaximumRate returns the maximum playback rate.
func (*Client) GetMetadata ¶
GetMetadata returns the current track metadata.
func (*Client) GetMinimumRate ¶
GetMinimumRate returns the minimum playback rate.
func (*Client) GetPlaybackStatus ¶
func (i *Client) GetPlaybackStatus() (PlaybackStatus, error)
GetPlaybackStatus returns the current playback status.
func (*Client) GetPlayerProperty ¶
GetPlayerProperty returns the prop from the player interface.
func (*Client) GetPlaylistsProperty ¶
GetPlaylistsProperty returns the prop from the playlists interface.
func (*Client) GetPosition ¶
GetPosition returns the current playback position.
func (*Client) GetProperty ¶
GetProperty returns the prop in the iface.
func (*Client) GetShuffle ¶
GetShuffle returns true if shuffle mode is enabled, false if playing linearly through a playlist.
func (*Client) GetSupportedURISchemes ¶
GetSupportedUriSchemes returns the supported URI schemes of the player.
func (*Client) GetTrackID ¶
func (i *Client) GetTrackID() (dbus.ObjectPath, error)
GetTrackID returns track id for player as dbus.ObjectPath.
func (*Client) GetTrackListProperty ¶
GetTrackListProperty returns the prop from the tracklist interface.
func (*Client) HasTrackList ¶
HasTrackList returns whether the player has a track list.
func (*Client) OnSeeked ¶
OnSeeked listens for "Seeked" signal and sends the new position as time.Duration to position until ctx is canceled.
func (*Client) PlayPause ¶
PlayPause resumes the current track if it's paused and pauses it if it's playing.
func (*Client) Seek ¶
Seek changes the current track position by the given offset. If the offset is negative, the playback position moves backward.
func (*Client) SetBaseProperty ¶
SetBaseProperty sets the propertyName from the base interface.
func (*Client) SetFullscreen ¶
SetFullscreen sets the fullscreen state of the player.
func (*Client) SetLoopStatus ¶
func (i *Client) SetLoopStatus(loopStatus LoopStatus) error
SetLoopStatus sets the loop status.
func (*Client) SetPlayerProperty ¶
SetPlayerProperty sets the propertyName from the player interface.
func (*Client) SetPlaylistsProperty ¶
SetPlaylistsProperty sets the propertyName from the playlists interface.
func (*Client) SetPosition ¶
SetPosition sets the playback position of the current track.
func (*Client) SetProperty ¶
SetProperty sets the value of a property in the interface.
func (*Client) SetShuffle ¶
SetShuffle sets the shuffle mode.
func (*Client) SetTrackListProperty ¶
SetTrackListProperty sets the propertyName from the tracklist interface.
func (*Client) SetTrackPosition ¶
SetTrackPosition sets the playback position of a specific track.
func (*Client) SupportedMimeTypes ¶
SupportedMimeTypes returns the supported MIME types of the player.
type LoopStatus ¶
type LoopStatus string
LoopStatus represents the loop status of the player. It can be "None", "Track" or "Playlist".
const ( LoopNone LoopStatus = "None" LoopTrack LoopStatus = "Track" LoopPlaylist LoopStatus = "Playlist" )
type Metadata ¶
Metadata represents the metadata of the current track.
type NoOpBaseHandler ¶
type NoOpBaseHandler struct{}
NoOpBaseHandler implement All method of BaseHandler.
func (NoOpBaseHandler) Quit ¶
func (NoOpBaseHandler) Quit() error
func (NoOpBaseHandler) Raise ¶
func (NoOpBaseHandler) Raise() error
type NoOpPlayerHandler ¶
type NoOpPlayerHandler struct{}
NoOpPlayerHandler implement All method of PlayerHandler.
func (NoOpPlayerHandler) Next ¶
func (NoOpPlayerHandler) Next() error
func (NoOpPlayerHandler) OpenURI ¶
func (NoOpPlayerHandler) OpenURI(string) error
func (NoOpPlayerHandler) Pause ¶
func (NoOpPlayerHandler) Pause() error
func (NoOpPlayerHandler) Play ¶
func (NoOpPlayerHandler) Play() error
func (NoOpPlayerHandler) PlayPause ¶
func (NoOpPlayerHandler) PlayPause() error
func (NoOpPlayerHandler) Previous ¶
func (NoOpPlayerHandler) Previous() error
func (NoOpPlayerHandler) SetPosition ¶
func (NoOpPlayerHandler) SetPosition(dbus.ObjectPath, time.Duration) error
func (NoOpPlayerHandler) Stop ¶
func (NoOpPlayerHandler) Stop() error
type NoOpPropertySetter ¶
type NoOpPropertySetter struct{}
NoOpPropertySetter implement All method of PropertySetter.
func (NoOpPropertySetter) SetFullscreen ¶
func (NoOpPropertySetter) SetFullscreen(fullscreen bool) error
func (NoOpPropertySetter) SetLoopStatus ¶
func (NoOpPropertySetter) SetLoopStatus(status LoopStatus) error
func (NoOpPropertySetter) SetRate ¶
func (NoOpPropertySetter) SetRate(rate float64) error
func (NoOpPropertySetter) SetShuffle ¶
func (NoOpPropertySetter) SetShuffle(shuffle bool) error
func (NoOpPropertySetter) SetVolume ¶
func (NoOpPropertySetter) SetVolume(volume float64) error
type PlaybackStatus ¶
type PlaybackStatus string
PlaybackStatus represents the playback status. It can be "Playing", "Paused" or "Stopped".
const ( PlaybackPlaying PlaybackStatus = "Playing" PlaybackPaused PlaybackStatus = "Paused" PlaybackStopped PlaybackStatus = "Stopped" )
type PlayerHandler ¶
type PlayerHandler interface {
Next() error
Previous() error
Pause() error
PlayPause() error
Stop() error
Play() error
Seek(offset time.Duration) error
SetPosition(trackID dbus.ObjectPath, position time.Duration) error
OpenURI(uri string) error
}
PlayerHandler defines the methods for the org.mpris.MediaPlayer2.Player interface.
type Properties ¶
type Properties struct {
// Base properties
CanQuit bool
Fullscreen bool
CanSetFullscreen bool
CanRaise bool
HasTrackList bool
Identity string
DesktopEntry string
SupportedUriSchemes []string
SupportedMimeTypes []string
// Player properties
PlaybackStatus PlaybackStatus
LoopStatus LoopStatus
Rate float64
Shuffle bool
Metadata Metadata
Volume float64
Position time.Duration
MinimumRate float64
MaximumRate float64
CanGoNext bool
CanGoPrevious bool
CanPlay bool
CanPause bool
CanSeek bool
CanControl bool
}
Properties contains all the properties supported by the MPRIS server.
type PropertiesManager ¶
type PropertiesManager struct {
// contains filtered or unexported fields
}
PropertiesManager manages access to MPRIS properties.
func NewPropertiesManager ¶
func NewPropertiesManager(p *Properties) *PropertiesManager
NewPropertiesManager creates a new PropertiesManager.
func (*PropertiesManager) SetProperty ¶
func (pm *PropertiesManager) SetProperty(f func(p *Properties))
SetProperty allows modifying properties safely.
type PropertySetter ¶
type PropertySetter interface {
SetFullscreen(fullscreen bool) error
SetLoopStatus(status LoopStatus) error
SetRate(rate float64) error
SetShuffle(shuffle bool) error
SetVolume(volume float64) error
}
PropertySetter handles write requests to MPRIS properties.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a mpris server.
func (*Server) RegisterBaseHandler ¶
func (s *Server) RegisterBaseHandler(handler BaseHandler) error
RegisterBaseHandler registers the base handler on the server.
func (*Server) RegisterPlayerHandler ¶
func (s *Server) RegisterPlayerHandler(handler PlayerHandler) error
RegisterPlayerHandler registers the player handler on the server.
func (*Server) RegisterPropertiesManager ¶
func (s *Server) RegisterPropertiesManager(pm *PropertiesManager, setter PropertySetter) error
RegisterPropertiesManager registers the property manager on the server.