Documentation ¶
Overview ¶
Package mpris implements the `mpris` interface to an instance of `mpd`.
Index ¶
- Constants
- type Instance
- type LoopStatus
- type MediaPlayer2
- type MetadataMap
- type Option
- type PlaybackRate
- type PlaybackStatus
- type Player
- func (p *Player) Next() *dbus.Error
- func (p *Player) OnLoopStatus(c *prop.Change) *dbus.Error
- func (p *Player) OnShuffle(c *prop.Change) *dbus.Error
- func (p *Player) OnVolume(c *prop.Change) *dbus.Error
- func (p *Player) Pause() *dbus.Error
- func (p *Player) Play() *dbus.Error
- func (p *Player) PlayPause() *dbus.Error
- func (p *Player) Previous() *dbus.Error
- func (p *Player) Seek(x TimeInUs) *dbus.Error
- func (p *Player) SetPosition(o TrackID, x TimeInUs) *dbus.Error
- func (p *Player) Stop() *dbus.Error
- type Status
- type TimeInUs
- type TrackID
- type TrackList
- type URI
Constants ¶
const TrackIDFormat = "/org/mpd/Tracks/%d"
TrackIDFormat is the formatter string for a track ID.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance is an instance of mpd-mpris. It contains a connection to the MPD server and the DBus connection.
func NewInstance ¶
NewInstance creates a new instance that takes care of the specified mpd.
func (*Instance) IntrospectNode ¶ added in v0.2.0
func (i *Instance) IntrospectNode() *introspect.Node
IntrospectNode returns the root node of the library's introspection output.
type LoopStatus ¶
type LoopStatus = string
LoopStatus is a repeat / loop status. https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Enum:Loop_Status
const ( LoopStatusNone LoopStatus = "None" LoopStatusTrack LoopStatus = "Track" LoopStatusPlaylist LoopStatus = "Playlist" )
Defined LoopStatuses
type MediaPlayer2 ¶
type MediaPlayer2 struct {
*Instance
}
MediaPlayer2 is a DBus object satisfying the `org.mpris.MediaPlayer2` interface.
func (*MediaPlayer2) Quit ¶
func (m *MediaPlayer2) Quit() *dbus.Error
Quit causes the media player to stop running. But for MPD, it's not up to the client to end its existence. Hence this function does nothing.
https://specifications.freedesktop.org/mpris-spec/latest/Media_Player.html#Method:Quit
func (*MediaPlayer2) Raise ¶
func (m *MediaPlayer2) Raise() *dbus.Error
Raise brings the media player's user interface to the front using any appropriate mechanism available. But for MPD, there's no User Interface, this function does nothing.
https://specifications.freedesktop.org/mpris-spec/latest/Media_Player.html#Method:Raise
type MetadataMap ¶
type MetadataMap map[string]interface{}
MetadataMap is a mapping from metadata attribute names to values. https://specifications.freedesktop.org/mpris-spec/latest/Track_List_Interface.html#Mapping:Metadata_Map
func MapFromSong ¶
func MapFromSong(s mpd.Song) MetadataMap
MapFromSong returns a MetadataMap from the Song struct in mpd.
type Option ¶ added in v0.2.1
type Option func(*Instance)
Option represents a togglable option.
func InstanceName ¶ added in v0.4.1
InstanceName gives a custom name after "mpd" for the MPRIS instance.
func NoInstance ¶ added in v0.2.1
func NoInstance() Option
NoInstance registers the instance's name without the instance# part.
type PlaybackRate ¶
type PlaybackRate float64
PlaybackRate is a playback rate. https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Simple-Type:Playback_Rate
type PlaybackStatus ¶
type PlaybackStatus string
PlaybackStatus is a playback state. https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Enum:Playback_Status
const ( PlaybackStatusPlaying PlaybackStatus = "Playing" PlaybackStatusPaused PlaybackStatus = "Paused" PlaybackStatusStopped PlaybackStatus = "Stopped" )
Defined PlaybackStatuses.
func PlaybackStatusFromMPD ¶ added in v0.3.1
func PlaybackStatusFromMPD(status string) (PlaybackStatus, error)
type Player ¶
type Player struct { *Instance // contains filtered or unexported fields }
Player is a DBus object satisfying the `org.mpris.MediaPlayer2.Player` interface. https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html
func (*Player) Next ¶
func (p *Player) Next() *dbus.Error
Next skips to the next track in the tracklist. https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:Next
func (*Player) OnLoopStatus ¶
OnLoopStatus handles LoopStatus change. https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Property:LoopStatus
func (*Player) OnShuffle ¶
OnShuffle handles Shuffle change. https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Property:Shuffle
func (*Player) Pause ¶
func (p *Player) Pause() *dbus.Error
Pause pauses playback. https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:Pause
func (*Player) Play ¶
func (p *Player) Play() *dbus.Error
Play starts or resumes playback. https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:Play
func (*Player) PlayPause ¶
func (p *Player) PlayPause() *dbus.Error
PlayPause toggles playback. If playback is already paused, resumes playback. If playback is stopped, starts playback. https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:PlayPause
func (*Player) Previous ¶
func (p *Player) Previous() *dbus.Error
Previous skips to the previous track in the tracklist. https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:Previous
func (*Player) Seek ¶
Seek seeks forward in the current track by the specified number of microseconds. https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:Seek
func (*Player) SetPosition ¶
SetPosition sets the current track position in microseconds. https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:SetPosition
func (*Player) Stop ¶
func (p *Player) Stop() *dbus.Error
Stop stops playback. https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:Stop
type Status ¶ added in v0.3.1
type Status struct { // Internal Status part PlaybackStatus PlaybackStatus LoopStatus LoopStatus Shuffle bool Volume float64 CurrentSong mpd.Song // Internal seek Seek time.Duration // contains filtered or unexported fields }
Status holds the internal status, as well as the corresponding props of the player's status.
type TimeInUs ¶
type TimeInUs int64
TimeInUs is time in microseconds. https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Simple-Type:Time_In_Us
func UsFromDuration ¶
UsFromDuration returns the type from a time.Duration
type TrackID ¶
type TrackID string
TrackID is the Unique track identifier. https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Simple-Type:Track_Id
type TrackList ¶
type TrackList struct {
*Instance
}
TrackList is a DBus object satisfying the `org.mpris.MediaPlayer2.TrackList` interface. https://specifications.freedesktop.org/mpris-spec/latest/TrackList_Interface.html
type URI ¶
type URI string
URI is an unique resource identifier. https://specifications.freedesktop.org/mpris-spec/latest/Track_List_Interface.html#Simple-Type:Uri