Documentation
¶
Index ¶
- func AlbumArtURL(deviceIP string, albumArtURI string) string
- func BuildRadioMeta(title string) string
- func ForceRadioURI(uri string) string
- func JoinURI(coordinatorUUID string) (string, error)
- func ParseEvent(payload []byte) (map[string]string, error)
- type AppleMusicKind
- type AppleMusicRef
- type BrowseResponse
- type Client
- func (c *Client) AddURIToQueue(ctx context.Context, enqueuedURI, enqueuedMeta string, ...) (firstTrackNumber int, err error)
- func (c *Client) BecomeCoordinatorOfStandaloneGroup(ctx context.Context) error
- func (c *Client) Browse(ctx context.Context, objectID string, start, count int) (BrowseResponse, error)
- func (c *Client) ClearQueue(ctx context.Context) error
- func (c *Client) EnqueueAppleMusic(ctx context.Context, input string, opts EnqueueOptions) (int, error)
- func (c *Client) EnqueueAppleMusicFromSMAPI(ctx context.Context, item SMAPIItem, serviceNum int, opts EnqueueOptions) (int, error)
- func (c *Client) EnqueueSpotify(ctx context.Context, input string, opts EnqueueOptions) (int, error)
- func (c *Client) GetDeviceDescription(ctx context.Context) (Device, error)
- func (c *Client) GetGroupMute(ctx context.Context) (bool, error)
- func (c *Client) GetGroupVolume(ctx context.Context) (int, error)
- func (c *Client) GetHouseholdID(ctx context.Context) (string, error)
- func (c *Client) GetMute(ctx context.Context) (bool, error)
- func (c *Client) GetPositionInfo(ctx context.Context) (PositionInfo, error)
- func (c *Client) GetString(ctx context.Context, variableName string) (string, error)
- func (c *Client) GetTopology(ctx context.Context) (Topology, error)
- func (c *Client) GetTransportInfo(ctx context.Context) (TransportInfo, error)
- func (c *Client) GetTransportSettings(ctx context.Context) (TransportSettings, error)
- func (c *Client) GetVolume(ctx context.Context) (int, error)
- func (c *Client) JoinGroup(ctx context.Context, coordinatorUUID string) error
- func (c *Client) LeaveGroup(ctx context.Context) error
- func (c *Client) ListAvailableServices(ctx context.Context) ([]MusicServiceDescriptor, error)
- func (c *Client) ListFavorites(ctx context.Context, start, count int) (FavoritesPage, error)
- func (c *Client) ListQueue(ctx context.Context, start, count int) (QueuePage, error)
- func (c *Client) Next(ctx context.Context) error
- func (c *Client) Pause(ctx context.Context) error
- func (c *Client) Play(ctx context.Context) error
- func (c *Client) PlayFavorite(ctx context.Context, favorite DIDLItem) error
- func (c *Client) PlayQueuePosition(ctx context.Context, position int) error
- func (c *Client) PlayURI(ctx context.Context, uri, meta string) error
- func (c *Client) Previous(ctx context.Context) error
- func (c *Client) PreviousOrRestart(ctx context.Context) error
- func (c *Client) RemoveAllTracksFromQueue(ctx context.Context) error
- func (c *Client) RemoveQueuePosition(ctx context.Context, position int) error
- func (c *Client) RemoveTrackFromQueue(ctx context.Context, oneBasedTrackNumber int) error
- func (c *Client) Renew(ctx context.Context, sub Subscription, requestedTimeout time.Duration) (Subscription, error)
- func (c *Client) SeekRelTime(ctx context.Context, hhmmss string) error
- func (c *Client) SeekTrackNumber(ctx context.Context, oneBasedTrackNumber int) error
- func (c *Client) SetAVTransportURI(ctx context.Context, uri, meta string) error
- func (c *Client) SetGroupMute(ctx context.Context, mute bool) error
- func (c *Client) SetGroupVolume(ctx context.Context, volume int) error
- func (c *Client) SetMute(ctx context.Context, mute bool) error
- func (c *Client) SetPlayMode(ctx context.Context, mode PlayMode) error
- func (c *Client) SetVolume(ctx context.Context, volume int) error
- func (c *Client) SnapshotGroupVolume(ctx context.Context) error
- func (c *Client) Stop(ctx context.Context) error
- func (c *Client) StopOrNoop(ctx context.Context) error
- func (c *Client) Subscribe(ctx context.Context, eventPath string, callbackURL string, ...) (Subscription, error)
- func (c *Client) SubscribeAVTransport(ctx context.Context, callbackURL string, requestedTimeout time.Duration) (Subscription, error)
- func (c *Client) SubscribeRenderingControl(ctx context.Context, callbackURL string, requestedTimeout time.Duration) (Subscription, error)
- func (c *Client) Unsubscribe(ctx context.Context, sub Subscription) error
- type DIDLItem
- type Device
- type DiscoverOptions
- type EnqueueOptions
- type FavoriteItem
- type FavoritesPage
- type FileSMAPITokenStore
- type Group
- type Member
- type MusicServiceAuthType
- type MusicServiceDescriptor
- type PlayMode
- type PositionInfo
- type QueueItem
- type QueuePage
- type SMAPIBeginAuthResult
- type SMAPIBrowseResult
- type SMAPIClient
- func (c *SMAPIClient) BeginAuthentication(ctx context.Context) (SMAPIBeginAuthResult, error)
- func (c *SMAPIClient) CompleteAuthentication(ctx context.Context, linkCode, linkDeviceID string) (SMAPITokenPair, error)
- func (c *SMAPIClient) GetMetadata(ctx context.Context, id string, index, count int, recursive bool) (SMAPIBrowseResult, error)
- func (c *SMAPIClient) Search(ctx context.Context, category, term string, index, count int) (SMAPISearchResult, error)
- func (c *SMAPIClient) SearchCategories(ctx context.Context) ([]string, error)
- type SMAPIItem
- type SMAPISearchResult
- type SMAPITokenPair
- type SMAPITokenStore
- type SpotifyKind
- type SpotifyRef
- type Subscription
- type Topology
- func (t Topology) CoordinatorIPFor(ip string) (string, bool)
- func (t Topology) CoordinatorIPForName(name string) (string, bool)
- func (t Topology) CoordinatorUUIDForIP(ip string) (string, bool)
- func (t Topology) CoordinatorUUIDForName(name string) (string, bool)
- func (t Topology) FindByIP(ip string) (Member, bool)
- func (t Topology) FindByName(name string) (Member, bool)
- func (t Topology) GroupForIP(ip string) (Group, bool)
- func (t Topology) GroupForName(name string) (Group, bool)
- type TransportInfo
- type TransportSettings
- type UPnPError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlbumArtURL ¶
AlbumArtURL returns an absolute URL for album art when Sonos returns a relative path.
func BuildRadioMeta ¶
BuildRadioMeta builds minimal DIDL metadata suitable for playing radio streams.
func ForceRadioURI ¶
ForceRadioURI converts an http/https/aac URI to the Sonos "mp3radio" scheme to force radio-style playback controls in the Sonos UI.
Types ¶
type AppleMusicKind ¶
type AppleMusicKind string
AppleMusicKind represents the type of Apple Music content.
const ( AppleMusicAlbum AppleMusicKind = "album" AppleMusicSong AppleMusicKind = "song" AppleMusicPlaylist AppleMusicKind = "playlist" AppleMusicStation AppleMusicKind = "station" )
type AppleMusicRef ¶
type AppleMusicRef struct {
Kind AppleMusicKind
ID string
Canonical string // Original URL or constructed identifier
ServiceNums []int // Sonos service numbers for Apple Music
}
AppleMusicRef holds parsed Apple Music reference information.
func ParseAppleMusicRef ¶
func ParseAppleMusicRef(input string) (AppleMusicRef, bool)
ParseAppleMusicRef parses an Apple Music URL or identifier and returns a reference.
type BrowseResponse ¶
type Client ¶
func (*Client) AddURIToQueue ¶
func (*Client) BecomeCoordinatorOfStandaloneGroup ¶
func (*Client) EnqueueAppleMusic ¶
func (c *Client) EnqueueAppleMusic(ctx context.Context, input string, opts EnqueueOptions) (int, error)
EnqueueAppleMusic enqueues Apple Music content to the speaker's queue. This method uses SMAPI search results which return properly formatted IDs.
func (*Client) EnqueueAppleMusicFromSMAPI ¶
func (c *Client) EnqueueAppleMusicFromSMAPI(ctx context.Context, item SMAPIItem, serviceNum int, opts EnqueueOptions) (int, error)
EnqueueAppleMusicFromSMAPI enqueues an Apple Music item returned from SMAPI search. The item parameter should have ID and Title from the SMAPI search result.
func (*Client) EnqueueSpotify ¶
func (*Client) GetDeviceDescription ¶
func (*Client) GetHouseholdID ¶
func (*Client) GetPositionInfo ¶
func (c *Client) GetPositionInfo(ctx context.Context) (PositionInfo, error)
func (*Client) GetTransportInfo ¶
func (c *Client) GetTransportInfo(ctx context.Context) (TransportInfo, error)
func (*Client) GetTransportSettings ¶
func (c *Client) GetTransportSettings(ctx context.Context) (TransportSettings, error)
GetTransportSettings returns the current play mode (shuffle/repeat) settings.
func (*Client) JoinGroup ¶
JoinGroup makes this speaker join the group coordinated by coordinatorUUID. This is typically done by sending AVTransport.SetAVTransportURI to the joining speaker with:
CurrentURI = x-rincon:<COORDINATOR_UUID>
func (*Client) LeaveGroup ¶
LeaveGroup ungroups this speaker, making it the coordinator of a standalone group.
func (*Client) ListAvailableServices ¶
func (c *Client) ListAvailableServices(ctx context.Context) ([]MusicServiceDescriptor, error)
func (*Client) ListFavorites ¶
func (*Client) PlayFavorite ¶
func (*Client) PlayQueuePosition ¶
func (*Client) PreviousOrRestart ¶
PreviousOrRestart attempts to go to the previous track. If the device rejects the transition (common for some streaming sources), it falls back to restarting the current track by seeking to 0:00:00.
func (*Client) RemoveAllTracksFromQueue ¶
func (*Client) RemoveQueuePosition ¶
func (*Client) RemoveTrackFromQueue ¶
func (*Client) Renew ¶
func (c *Client) Renew(ctx context.Context, sub Subscription, requestedTimeout time.Duration) (Subscription, error)
func (*Client) SeekTrackNumber ¶
func (*Client) SetAVTransportURI ¶
func (*Client) SetGroupVolume ¶
func (*Client) SetPlayMode ¶
SetPlayMode sets the playback mode (shuffle/repeat). Valid modes: NORMAL, SHUFFLE, SHUFFLE_NOREPEAT, REPEAT_ALL, REPEAT_ONE
func (*Client) SnapshotGroupVolume ¶
func (*Client) StopOrNoop ¶
StopOrNoop attempts to stop playback. Some sources (e.g. TV input via x-sonos-htastream) reject Stop with UPnP error 701 (Transition not available). In that case, this is treated as a successful no-op.
func (*Client) SubscribeAVTransport ¶
func (*Client) SubscribeRenderingControl ¶
func (*Client) Unsubscribe ¶
func (c *Client) Unsubscribe(ctx context.Context, sub Subscription) error
type DIDLItem ¶
type DIDLItem struct {
ID string `json:"id"`
Title string `json:"title"`
URI string `json:"uri"`
Class string `json:"class,omitempty"`
Artist string `json:"artist,omitempty"`
Album string `json:"album,omitempty"`
AlbumArtURI string `json:"albumArtURI,omitempty"`
ResMD string `json:"resMD,omitempty"`
}
func ParseDIDLItems ¶
func ParseNowPlaying ¶
ParseNowPlaying attempts to parse a DIDL-Lite TrackMetaData payload into a single DIDLItem.
type Device ¶
type DiscoverOptions ¶
type EnqueueOptions ¶
type FavoriteItem ¶
type FavoritesPage ¶
type FavoritesPage struct {
Items []FavoriteItem `json:"items"`
NumberReturned int `json:"numberReturned"`
TotalMatches int `json:"totalMatches"`
UpdateID int `json:"updateID"`
}
type FileSMAPITokenStore ¶
type FileSMAPITokenStore struct {
// contains filtered or unexported fields
}
func NewDefaultSMAPITokenStore ¶
func NewDefaultSMAPITokenStore() (*FileSMAPITokenStore, error)
func NewFileSMAPITokenStore ¶
func NewFileSMAPITokenStore(path string) (*FileSMAPITokenStore, error)
func (*FileSMAPITokenStore) Has ¶
func (s *FileSMAPITokenStore) Has(serviceID, householdID string) bool
func (*FileSMAPITokenStore) Load ¶
func (s *FileSMAPITokenStore) Load(serviceID, householdID string) (SMAPITokenPair, bool, error)
func (*FileSMAPITokenStore) Save ¶
func (s *FileSMAPITokenStore) Save(serviceID, householdID string, pair SMAPITokenPair) error
type MusicServiceAuthType ¶
type MusicServiceAuthType string
const ( MusicServiceAuthAnonymous MusicServiceAuthType = "Anonymous" MusicServiceAuthUserID MusicServiceAuthType = "UserId" MusicServiceAuthDeviceLink MusicServiceAuthType = "DeviceLink" MusicServiceAuthAppLink MusicServiceAuthType = "AppLink" )
type MusicServiceDescriptor ¶
type MusicServiceDescriptor struct {
ID string `json:"id"`
Name string `json:"name"`
Version string `json:"version"`
URI string `json:"uri"`
SecureURI string `json:"secureUri"`
Capabilities string `json:"capabilities"`
ContainerType string `json:"containerType"`
Auth MusicServiceAuthType `json:"auth"`
ServiceType string `json:"serviceType"`
PresentationMapURI string `json:"presentationMapUri,omitempty"`
StringsURI string `json:"stringsUri,omitempty"`
ManifestURI string `json:"manifestUri,omitempty"`
}
type PlayMode ¶
type PlayMode string
PlayMode represents the playback mode (shuffle/repeat settings). Valid values: NORMAL, SHUFFLE, SHUFFLE_NOREPEAT, REPEAT_ALL, REPEAT_ONE
type PositionInfo ¶
type SMAPIBeginAuthResult ¶
type SMAPIBrowseResult ¶
type SMAPIClient ¶
type SMAPIClient struct {
Service MusicServiceDescriptor
HouseholdID string
DeviceID string
TokenStore SMAPITokenStore
// contains filtered or unexported fields
}
func NewSMAPIClient ¶
func NewSMAPIClient(ctx context.Context, speaker *Client, svc MusicServiceDescriptor, store SMAPITokenStore) (*SMAPIClient, error)
func (*SMAPIClient) BeginAuthentication ¶
func (c *SMAPIClient) BeginAuthentication(ctx context.Context) (SMAPIBeginAuthResult, error)
func (*SMAPIClient) CompleteAuthentication ¶
func (c *SMAPIClient) CompleteAuthentication(ctx context.Context, linkCode, linkDeviceID string) (SMAPITokenPair, error)
func (*SMAPIClient) GetMetadata ¶
func (c *SMAPIClient) GetMetadata(ctx context.Context, id string, index, count int, recursive bool) (SMAPIBrowseResult, error)
func (*SMAPIClient) Search ¶
func (c *SMAPIClient) Search(ctx context.Context, category, term string, index, count int) (SMAPISearchResult, error)
func (*SMAPIClient) SearchCategories ¶
func (c *SMAPIClient) SearchCategories(ctx context.Context) ([]string, error)
type SMAPISearchResult ¶
type SMAPITokenPair ¶
type SMAPITokenPair struct {
AuthToken string `json:"authToken"`
PrivateKey string `json:"privateKey"`
UpdatedAt time.Time `json:"updatedAt"`
LinkCode string `json:"linkCode,omitempty"` // optional, for debugging
DeviceID string `json:"deviceId,omitempty"` // optional, for debugging
HouseholdID string `json:"householdId,omitempty"` // optional, for debugging
}
type SMAPITokenStore ¶
type SMAPITokenStore interface {
Has(serviceID, householdID string) bool
Load(serviceID, householdID string) (SMAPITokenPair, bool, error)
Save(serviceID, householdID string, pair SMAPITokenPair) error
}
type SpotifyKind ¶
type SpotifyKind string
const ( SpotifyAlbum SpotifyKind = "album" SpotifyEpisode SpotifyKind = "episode" SpotifyPlaylist SpotifyKind = "playlist" SpotifyShow SpotifyKind = "show" SpotifyTrack SpotifyKind = "track" )
type SpotifyRef ¶
type SpotifyRef struct {
Kind SpotifyKind
ID string
Canonical string // spotify:<kind>:<id>
EncodedID string // spotify%3a<kind>%3a<id>
ServiceNums []int // possible Sonos service numbers
}
func ParseSpotifyRef ¶
func ParseSpotifyRef(input string) (SpotifyRef, bool)
type Topology ¶
type Topology struct {
Groups []Group `json:"groups"`
ByName map[string]Member `json:"-"`
ByIP map[string]Member `json:"-"`
// contains filtered or unexported fields
}
func (Topology) CoordinatorIPForName ¶
func (Topology) CoordinatorUUIDForIP ¶
func (Topology) CoordinatorUUIDForName ¶
type TransportInfo ¶
type TransportSettings ¶
TransportSettings holds the current play mode and rec quality mode.
Source Files
¶
- applemusic.go
- avtransport.go
- client.go
- content_directory.go
- device.go
- device_properties.go
- didl.go
- discover.go
- event_parse.go
- events.go
- favorites.go
- group.go
- group_rendering.go
- http_fallback.go
- music_services.go
- now_playing.go
- play_uri.go
- queue.go
- rendering.go
- services.go
- smapi.go
- smapi_pmap.go
- smapi_tokens.go
- soap.go
- spotify.go
- ssdp.go
- system_properties.go
- topology.go