Documentation
¶
Index ¶
- func IsServiceStarted(conn *dbus.Conn) (bool, error)
- func Listen(conn *dbus.Conn, listeners *Listeners)
- func SendNext(conn *dbus.Conn) error
- func SendPause(conn *dbus.Conn) error
- func SendPlay(conn *dbus.Conn) error
- func SendPlayPause(conn *dbus.Conn) error
- func SendPrevious(conn *dbus.Conn) error
- type Listeners
- type Metadata
- type PlaybackStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsServiceStarted ¶
IsServiceStarted checks if the Spotify app is running
func Listen ¶
Listen will listen for any changes in PlayPause or metadata from the Spotify app
This function is blocking
func SendNext ¶
SendNext sends a "Next" message to the Spotify app. Returns error if anything goes wrong. If the Spotify app is not running, return nil
func SendPause ¶
SendPause sends a "Pause" message to the Spotify app. Returns error if anything goes wrong. If the Spotify app is not running, return nil
func SendPlay ¶
SendPlay sends a "Play" message to the Spotify app. Returns error if anything goes wrong. If the Spotify app is not running, return nil
func SendPlayPause ¶
SendPlayPause sends a "PlayPause" message to the Spotify app. Returns error if anything goes wrong. If the Spotify app is not running, return nil
func SendPrevious ¶
SendPrevious sends a "Previous" message to the Spotify app. Returns error if anything goes wrong. If the Spotify app is not running, return nil
Types ¶
type Listeners ¶
type Listeners struct { OnMetadata func(*Metadata) OnPlaybackStatus func(PlaybackStatus) OnServiceStart func() OnServiceStop func() OnError func(error) }
Listeners is a struct of the events we are listening for
func NewListeners ¶ added in v0.2.0
func NewListeners() *Listeners
NewListeners returns default listeners
type Metadata ¶
type Metadata struct { Artist []string `spotify:"xesam:artist"` Title string `spotify:"xesam:title"` Album string `spotify:"xesam:album"` AlbumArtist []string `spotify:"xesam:albumArtist"` AutoRating float64 `spotify:"xesam:autoRating"` DiskNumber int32 `spotify:"xesam:discNumber"` TrackNumber int32 `spotify:"xesam:trackNumber"` URL string `spotify:"xesam:url"` TrackID string `spotify:"mpris:trackid"` Length uint64 `spotify:"mpris:length"` }
Metadata contains Spotify player metadata
type PlaybackStatus ¶
type PlaybackStatus string
PlaybackStatus is a PlayPause status of a music player
const ( // StatusPlaying is the playing state StatusPlaying PlaybackStatus = "Playing" // StatusPaused is the paused state StatusPaused PlaybackStatus = "Paused" // StatusUnknown is an unknown music player state StatusUnknown PlaybackStatus = "Unknown" )
func GetPlaybackStatus ¶
func GetPlaybackStatus(conn *dbus.Conn) (PlaybackStatus, error)
GetPlaybackStatus returns the current Play/Pause status of the Spotify app Status will be "Playing", "Paused" or "Unknown"