spotify

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2019 License: MIT Imports: 4 Imported by: 4

README

go-spotify-dbus

GoDoc Build Status Go Report Card

Simple library that helps interacting with Spotify dbus interface.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsServiceStarted

func IsServiceStarted(conn *dbus.Conn) (bool, error)

IsServiceStarted checks if the Spotify app is running

func Listen

func Listen(conn *dbus.Conn, listeners *Listeners)

Listen will listen for any changes in PlayPause or metadata from the Spotify app

This function is blocking

func SendNext

func SendNext(conn *dbus.Conn) error

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

func SendPause(conn *dbus.Conn) error

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

func SendPlay(conn *dbus.Conn) error

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

func SendPlayPause(conn *dbus.Conn) error

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

func SendPrevious(conn *dbus.Conn) error

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

func GetMetadata

func GetMetadata(conn *dbus.Conn) (*Metadata, error)

GetMetadata returns the current metadata from the Spotify app

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"

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL