Documentation
¶
Index ¶
- Constants
- func ConvertSpotifyURIWithMetadata(uri string) (sonosURI, metadata string)
- func ExtractSpotifyTrackID(uri string) string
- func IsSpotifySource(uri string) bool
- type Client
- func (c *Client) AddToGroup(ctx context.Context, device *Device, coordinatorUUID string) error
- func (c *Client) AddURIToQueue(ctx context.Context, device *Device, uri, metadata string) error
- func (c *Client) ClearQueue(ctx context.Context, device *Device) error
- func (c *Client) Discover(ctx context.Context) ([]*Device, error)
- func (c *Client) DiscoverFresh(ctx context.Context) ([]*Device, error)
- func (c *Client) GetDevice(identifier string) *Device
- func (c *Client) GetDeviceInfo(ctx context.Context, device *Device) (*DeviceInfo, error)
- func (c *Client) GetMediaInfo(ctx context.Context, device *Device) (*MediaInfo, error)
- func (c *Client) GetMusicServices(ctx context.Context, device *Device) ([]MusicService, error)
- func (c *Client) GetPositionInfo(ctx context.Context, device *Device) (*PositionInfo, error)
- func (c *Client) GetTransportInfo(ctx context.Context, device *Device) (*TransportInfo, error)
- func (c *Client) GetVolume(ctx context.Context, device *Device) (int, error)
- func (c *Client) GetZoneGroupState(ctx context.Context, device *Device) (*ZoneGroupState, error)
- func (c *Client) InvalidateGroupCache()
- func (c *Client) IsPlaying(ctx context.Context, device *Device) (bool, error)
- func (c *Client) ListGroups(ctx context.Context, device *Device) ([]Group, error)
- func (c *Client) Next(ctx context.Context, device *Device) error
- func (c *Client) Pause(ctx context.Context, device *Device) error
- func (c *Client) Play(ctx context.Context, device *Device) error
- func (c *Client) PlayFromQueue(ctx context.Context, device *Device) error
- func (c *Client) PlayURI(ctx context.Context, device *Device, uri, metadata string) error
- func (c *Client) Previous(ctx context.Context, device *Device) error
- func (c *Client) RemoveFromGroup(ctx context.Context, device *Device) error
- func (c *Client) Seek(ctx context.Context, device *Device, target string) error
- func (c *Client) SetAlias(alias, target string)
- func (c *Client) SetVolume(ctx context.Context, device *Device, volume int) error
- type DIDLItem
- type DIDLLite
- type Device
- type DeviceInfo
- type Discovery
- type Group
- type MediaInfo
- type MusicService
- type Player
- func (p *Player) AddToQueue(ctx context.Context, trackURI string) error
- func (p *Player) GetQueue(ctx context.Context) (*core.Queue, error)
- func (p *Player) GetRecentlyPlayed(ctx context.Context, limit int) ([]core.HistoryEntry, error)
- func (p *Player) GetState(ctx context.Context) (*core.PlaybackState, error)
- func (p *Player) Next(ctx context.Context) error
- func (p *Player) Pause(ctx context.Context) error
- func (p *Player) Play(ctx context.Context) error
- func (p *Player) PlayURI(ctx context.Context, uri string) error
- func (p *Player) Prev(ctx context.Context) error
- func (p *Player) Seek(ctx context.Context, positionMs int) error
- func (p *Player) Volume(ctx context.Context, percent int) error
- type PositionInfo
- type SOAPBody
- type SOAPClient
- type SOAPEnvelope
- type TransportInfo
- type ZoneGroupState
Constants ¶
const ( // UPnP service endpoints AVTransportEndpoint = "/MediaRenderer/AVTransport/Control" RenderingControlEndpoint = "/MediaRenderer/RenderingControl/Control" ZoneGroupTopologyEndpoint = "/ZoneGroupTopology/Control" DevicePropertiesEndpoint = "/DeviceProperties/Control" // UPnP service URNs AVTransportService = "urn:schemas-upnp-org:service:AVTransport:1" RenderingControlService = "urn:schemas-upnp-org:service:RenderingControl:1" ZoneGroupTopologyService = "urn:upnp-org:serviceId:ZoneGroupTopology" DevicePropertiesService = "urn:upnp-org:serviceId:DeviceProperties" )
Variables ¶
This section is empty.
Functions ¶
func ConvertSpotifyURIWithMetadata ¶
ConvertSpotifyURIWithMetadata converts a Spotify URI to Sonos format with DIDL-Lite metadata.
func ExtractSpotifyTrackID ¶
ExtractSpotifyTrackID extracts a Spotify track ID from a Sonos URI.
func IsSpotifySource ¶
IsSpotifySource returns true if the URI indicates Spotify content.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides high-level access to Sonos devices.
func (*Client) AddToGroup ¶
AddToGroup adds a device to a group.
func (*Client) AddURIToQueue ¶
AddURIToQueue adds a URI to the playback queue.
func (*Client) ClearQueue ¶
ClearQueue removes all items from the playback queue.
func (*Client) Discover ¶
Discover finds all Sonos devices on the network. Uses cached results from ~/.cache/riff/sonos-devices.json if available.
func (*Client) DiscoverFresh ¶
DiscoverFresh bypasses the cache and performs fresh SSDP discovery.
func (*Client) GetDeviceInfo ¶
GetDeviceInfo retrieves device information.
func (*Client) GetMediaInfo ¶
GetMediaInfo retrieves current media information.
func (*Client) GetMusicServices ¶
GetMusicServices retrieves configured music services from the Sonos.
func (*Client) GetPositionInfo ¶
GetPositionInfo retrieves the current track position.
func (*Client) GetTransportInfo ¶
GetTransportInfo retrieves the current transport state.
func (*Client) GetVolume ¶
GetVolume retrieves the current volume level (0-100). Results are cached for a short period to reduce network calls.
func (*Client) GetZoneGroupState ¶
GetZoneGroupState retrieves the current zone group topology.
func (*Client) InvalidateGroupCache ¶
func (c *Client) InvalidateGroupCache()
InvalidateGroupCache clears the zone group cache.
func (*Client) ListGroups ¶
ListGroups returns all speaker groups. Results are cached for a short period to reduce network calls.
func (*Client) PlayFromQueue ¶
PlayFromQueue starts playback from the queue.
func (*Client) RemoveFromGroup ¶
RemoveFromGroup removes a device from its group (makes it standalone).
type DIDLItem ¶
type DIDLItem struct {
// Dublin Core namespace elements
Title string `xml:"http://purl.org/dc/elements/1.1/ title"`
Creator string `xml:"http://purl.org/dc/elements/1.1/ creator"`
// UPnP namespace elements
Album string `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ album"`
AlbumArtURI string `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ albumArtURI"`
Class string `xml:"urn:schemas-upnp-org:metadata-1-0/upnp/ class"`
// Default namespace
Res string `xml:"res"`
}
DIDLItem represents a single item in DIDL-Lite metadata.
type DIDLLite ¶
type DIDLLite struct {
XMLName xml.Name `xml:"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/ DIDL-Lite"`
Items []DIDLItem `xml:"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/ item"`
}
DIDLLite represents DIDL-Lite metadata format used by UPnP.
type Device ¶
type Device struct {
IP string `json:"ip"`
Port int `json:"port"`
UUID string `json:"uuid"`
Model string `json:"model"`
Name string `json:"name"`
Location string `json:"location"`
LastSeen time.Time `json:"last_seen"`
}
Device represents a discovered Sonos device.
type DeviceInfo ¶
type DeviceInfo struct {
RoomName string `xml:"RoomName"`
ModelName string `xml:"ModelName"`
ModelNumber string `xml:"ModelNumber"`
SerialNumber string `xml:"SerialNumber"`
SoftwareVersion string `xml:"SoftwareVersion"`
}
DeviceInfo contains detailed device information.
type Discovery ¶
type Discovery struct {
// contains filtered or unexported fields
}
Discovery handles Sonos device discovery via SSDP.
func NewDiscovery ¶
NewDiscovery creates a new Discovery instance.
func (*Discovery) CachedDevices ¶
CachedDevices returns all cached devices that haven't expired.
func (*Discovery) Discover ¶
Discover performs SSDP discovery and returns all found Sonos devices. Results are cached to ~/.cache/riff/sonos-devices.json for faster subsequent lookups.
func (*Discovery) DiscoverFresh ¶
DiscoverFresh bypasses the cache and performs fresh SSDP discovery.
type Group ¶
type Group struct {
ID string `json:"id"`
Coordinator *Device `json:"coordinator"`
Members []*Device `json:"members"`
Name string `json:"name"`
}
Group represents a Sonos speaker group.
type MediaInfo ¶
type MediaInfo struct {
NrTracks int `xml:"NrTracks"`
MediaDuration string `xml:"MediaDuration"`
CurrentURI string `xml:"CurrentURI"`
CurrentURIMetaData string `xml:"CurrentURIMetaData"`
}
MediaInfo contains current media information.
type MusicService ¶
MusicService represents a configured music service on the Sonos.
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player implements core.Player for Sonos devices.
func (*Player) AddToQueue ¶
AddToQueue adds a track to the queue.
func (*Player) GetRecentlyPlayed ¶ added in v0.2.0
GetRecentlyPlayed returns recently played tracks. Sonos doesn't have a recently played API, so this returns empty.
type PositionInfo ¶
type PositionInfo struct {
Track int `xml:"Track"`
TrackDuration string `xml:"TrackDuration"`
TrackMetaData string `xml:"TrackMetaData"`
TrackURI string `xml:"TrackURI"`
RelTime string `xml:"RelTime"`
AbsTime string `xml:"AbsTime"`
}
PositionInfo contains track position information.
type SOAPBody ¶
type SOAPBody struct {
Content []byte `xml:",innerxml"`
}
SOAPBody contains the SOAP body content.
type SOAPClient ¶
type SOAPClient struct {
// contains filtered or unexported fields
}
SOAPClient makes SOAP requests to Sonos devices.
type SOAPEnvelope ¶
type SOAPEnvelope struct {
XMLName xml.Name `xml:"s:Envelope"`
NS string `xml:"xmlns:s,attr"`
Body SOAPBody `xml:"s:Body"`
}
SOAPEnvelope wraps a SOAP request/response.
type TransportInfo ¶
type TransportInfo struct {
CurrentTransportState string
CurrentTransportStatus string
CurrentSpeed string
}
TransportInfo contains playback transport state.
type ZoneGroupState ¶
type ZoneGroupState struct {
Groups []Group `json:"groups"`
}
ZoneGroupState contains the parsed zone group topology.