Documentation
¶
Index ¶
- Constants
- func GetDevices(s *auth.Session) (*[]Device, error)
- type Device
- type Player
- func (p *Player) Device() *Device
- func (p *Player) Pause(s *auth.Session) error
- func (p *Player) Play(contextUri string, uri string, s *auth.Session) error
- func (p *Player) Resume(s *auth.Session, play bool) error
- func (p *Player) SeekToPosition(s *auth.Session, pos int) error
- func (p *Player) SetDevice(d *Device, c *config.Config) error
- func (p *Player) SetVolume(s *auth.Session, val int) error
- func (p *Player) Shuffle(state bool, s *auth.Session) error
- func (p *Player) SkipNext(s *auth.Session) error
- func (p *Player) SkipPrev(s *auth.Session) error
- func (p *Player) State(s *auth.Session) (*PlayerState, error)
- type PlayerState
Constants ¶
const ( TRACK_TYPE = "track" EPISODE_TYPE = "episode" AD_TYPE = "ad" UNKNOWN_TYPE = "unknown" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Device ¶ added in v0.2.0
type Device struct {
ID string `json:"id"`
IsActive bool `json:"is_active"`
Name string `json:"name"`
Type string `json:"type"`
VolumePercent int `json:"volume_percent"`
}
Device represents a spotify playback device. There is no guarantee that the device is still valid or active on the user's device since it will be cached.
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
func New ¶
Creates a new player, getting device to any cached device or nil if no devices were found in cache.
func (*Player) Play ¶
ContextUri can be the uri of an album or playlist. Uri should be a track contained in the album or playlist.
func (*Player) Resume ¶
Resume uses the "transfer playback device" endpoint instead of the "resume playback" to ensure playback is always transfered to selected device before the players resumes playback.
func (*Player) SeekToPosition ¶
Seeks to given position in milliseconds to user's current playing track.
func (*Player) SetDevice ¶
Sets the playback device for player and saves playback device into cache file "device.json".
type PlayerState ¶
type PlayerState struct {
CurrentPlayingType string `json:"currently_playing_type"`
Device *Device `json:"device"`
ProgressMs int `json:"progress_ms"`
IsPlaying bool `json:"is_playing"`
ShuffleState bool `json:"shuffle_state"`
// Each PlayerState will have either a nil track or episode,
// depending on what the user is playing.
Track *spotify.Track
Episode *spotify.Episode
// Only used to retrieve the current item and
// transfer into either a track or episode.
Item interface{} `json:"item"`
}