sonos

package module
v0.0.0-...-d57ea70 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: MIT Imports: 29 Imported by: 0

README

No Maintenance Intended

No Maintenance Intended

Credits

Forked from https://github.com/szatmary/sonos.

Changes

There are few changes have been made mostly around the structure of the generated code and how it is consumed. There are also improvements to the event lifecycle (subscribe/renew/unsubscribe) with some other miscellaneous changes.

Services

The service implimentations are automatically generated from the service definition XML files obtained from the Sonos devices via makeservice.go.

cmd/makeservices/downloadallservices.sh fetches them from the device and cmd/makeservices/makeallservices.sh generates the code.

More

Please see https://svrooij.io/sonos-api-docs/sonos-communication.html and https://svrooij.io/sonos-api-docs/services/ for Sonos API and http://upnp.org/ for UPnP.

Documentation

Overview

Package sonos provides an implementation of the Sonos UPnP API.

This package allows discovery, control, and event subscription for Sonos devices on the local network.

Basic Usage:

package main

import (
	"context"
	"log"
	"time"

	"github.com/caglar10ur/sonos"
)

func main() {
	s, err := sonos.NewSonos()
	if err != nil {
		log.Fatal(err)
	}
	defer s.Close()

	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
	defer cancel()

	// Discover devices
	s.Search(ctx, func(s *sonos.Sonos, zp *sonos.ZonePlayer) {
		log.Printf("Found device: %s (%s)", zp.RoomName(), zp.IPAddress())

		// Control the device (e.g., GetVolume)
		vol, err := zp.GetVolume()
		if err != nil {
			log.Printf("Error getting volume: %v", err)
			return
		}
		log.Printf("Current volume: %d", vol)
	})

	<-ctx.Done()
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromEndpoint

func FromEndpoint(endpoint string) (*url.URL, error)

func FromLocation

func FromLocation(location string) (*url.URL, error)

Types

type AVTransportInstanceID

type AVTransportInstanceID struct {
	TransportState               TransportState               `xml:"TransportState"`
	CurrentPlayMode              CurrentPlayMode              `xml:"CurrentPlayMode"`
	CurrentCrossfadeMode         CurrentCrossfadeMode         `xml:"CurrentCrossfadeMode"`
	NumberOfTracks               NumberOfTracks               `xml:"NumberOfTracks"`
	CurrentTrack                 CurrentTrack                 `xml:"CurrentTrack"`
	CurrentSection               CurrentSection               `xml:"CurrentSection"`
	CurrentTrackURI              CurrentTrackURI              `xml:"CurrentTrackURI"`
	CurrentTrackDuration         CurrentTrackDuration         `xml:"CurrentTrackDuration"`
	CurrentTrackMetaData         CurrentTrackMetaData         `xml:"CurrentTrackMetaData"`
	NextTrackURI                 NextTrackURI                 `xml:"NextTrackURI"`
	NextTrackMetaData            NextTrackMetaData            `xml:"NextTrackMetaData"`
	EnqueuedTransportURI         EnqueuedTransportURI         `xml:"EnqueuedTransportURI"`
	EnqueuedTransportURIMetaData EnqueuedTransportURIMetaData `xml:"EnqueuedTransportURIMetaData"`
	PlaybackStorageMedium        PlaybackStorageMedium        `xml:"PlaybackStorageMedium"`
	AVTransportURI               AVTransportURI               `xml:"AVTransportURI"`
	AVTransportURIMetaData       AVTransportURIMetaData       `xml:"AVTransportURIMetaData"`
	NextAVTransportURI           NextAVTransportURI           `xml:"NextAVTransportURI"`
	NextAVTransportURIMetaData   NextAVTransportURIMetaData   `xml:"NextAVTransportURIMetaData"`
	CurrentTransportActions      CurrentTransportActions      `xml:"CurrentTransportActions"`
	CurrentValidPlayModes        CurrentValidPlayModes        `xml:"CurrentValidPlayModes"`
	DirectControlClientID        DirectControlClientID        `xml:"DirectControlClientID"`
	DirectControlIsSuspended     DirectControlIsSuspended     `xml:"DirectControlIsSuspended"`
	DirectControlAccountID       DirectControlAccountID       `xml:"DirectControlAccountID"`
	TransportStatus              TransportStatus              `xml:"TransportStatus"`
	SleepTimerGeneration         SleepTimerGeneration         `xml:"SleepTimerGeneration"`
	AlarmRunning                 AlarmRunning                 `xml:"AlarmRunning"`
	SnoozeRunning                SnoozeRunning                `xml:"SnoozeRunning"`
	RestartPending               RestartPending               `xml:"RestartPending"`
	TransportPlaySpeed           TransportPlaySpeed           `xml:"TransportPlaySpeed"`
	CurrentMediaDuration         CurrentMediaDuration         `xml:"CurrentMediaDuration"`
	RecordStorageMedium          RecordStorageMedium          `xml:"RecordStorageMedium"`
	PossiblePlaybackStorageMedia PossiblePlaybackStorageMedia `xml:"PossiblePlaybackStorageMedia"`
	PossibleRecordStorageMedia   PossibleRecordStorageMedia   `xml:"PossibleRecordStorageMedia"`
	RecordMediumWriteStatus      RecordMediumWriteStatus      `xml:"RecordMediumWriteStatus"`
	CurrentRecordQualityMode     CurrentRecordQualityMode     `xml:"CurrentRecordQualityMode"`
	PossibleRecordQualityModes   PossibleRecordQualityModes   `xml:"PossibleRecordQualityModes"`
}

type AVTransportLastChange

type AVTransportLastChange struct {
	InstanceID AVTransportInstanceID `xml:"InstanceID"`
}

http://upnp.org/specs/av/UPnP-av-AVTransport-v1-Service.pdf

func (*AVTransportLastChange) String

func (e *AVTransportLastChange) String() string

type AVTransportURI

type AVTransportURI struct {
	Value string `xml:"val,attr"`
}

type AVTransportURIMetaData

type AVTransportURIMetaData struct {
	Value string `xml:"val,attr"`
}

type AlarmRunning

type AlarmRunning struct {
	Value string `xml:"val,attr"`
}

type Bass

type Bass struct {
	Value string `xml:"val,attr"`
}

type Curated

type Curated struct {
	Value string `xml:"val,attr"`
}

type CurrentCrossfadeMode

type CurrentCrossfadeMode struct {
	Value string `xml:"val,attr"`
}

type CurrentMediaDuration

type CurrentMediaDuration struct {
	Value string `xml:"val,attr"`
}

type CurrentPlayMode

type CurrentPlayMode struct {
	Value string `xml:"val,attr"`
}

type CurrentRecordQualityMode

type CurrentRecordQualityMode struct {
	Value string `xml:"val,attr"`
}

type CurrentSection

type CurrentSection struct {
	Value string `xml:"val,attr"`
}

type CurrentTrack

type CurrentTrack struct {
	Value string `xml:"val,attr"`
}

type CurrentTrackDuration

type CurrentTrackDuration struct {
	Value string `xml:"val,attr"`
}

type CurrentTrackMetaData

type CurrentTrackMetaData struct {
	Value string `xml:"val,attr"`
}

type CurrentTrackURI

type CurrentTrackURI struct {
	Value string `xml:"val,attr"`
}

type CurrentTransportActions

type CurrentTransportActions struct {
	Value string `xml:"val,attr"`
}

type CurrentValidPlayModes

type CurrentValidPlayModes struct {
	Value string `xml:"val,attr"`
}

type Device

type Device struct {
	XMLName                 xml.Name  `xml:"device"`
	DeviceType              string    `xml:"deviceType"`
	FriendlyName            string    `xml:"friendlyName"`
	Manufacturer            string    `xml:"manufacturer"`
	ManufacturerURL         string    `xml:"manufacturerURL"`
	ModelNumber             string    `xml:"modelNumber"`
	ModelDescription        string    `xml:"modelDescription"`
	ModelName               string    `xml:"modelName"`
	ModelURL                string    `xml:"modelURL"`
	SoftwareVersion         string    `xml:"softwareVersion"`
	SwGen                   string    `xml:"swGen"`
	HardwareVersion         string    `xml:"hardwareVersion"`
	SerialNum               string    `xml:"serialNum"`
	MACAddress              string    `xml:"MACAddress"`
	UDN                     string    `xml:"UDN"`
	Icons                   []Icon    `xml:"iconList>icon"`
	MinCompatibleVersion    string    `xml:"minCompatibleVersion"`
	LegacyCompatibleVersion string    `xml:"legacyCompatibleVersion"`
	APIVersion              string    `xml:"apiVersion"`
	MinAPIVersion           string    `xml:"minApiVersion"`
	DisplayVersion          string    `xml:"displayVersion"`
	ExtraVersion            string    `xml:"extraVersion"`
	RoomName                string    `xml:"roomName"`
	DisplayName             string    `xml:"displayName"`
	ZoneType                int       `xml:"zoneType"`
	Feature1                string    `xml:"feature1"`
	Feature2                string    `xml:"feature2"`
	Feature3                string    `xml:"feature3"`
	Seriesid                string    `xml:"seriesid"`
	Variant                 int       `xml:"variant"`
	InternalSpeakerSize     float32   `xml:"internalSpeakerSize"`
	BassExtension           float32   `xml:"bassExtension"`
	SatGainOffset           float32   `xml:"satGainOffset"`
	Memory                  int       `xml:"memory"`
	Flash                   int       `xml:"flash"`
	FlashRepartitioned      int       `xml:"flashRepartitioned"`
	AmpOnTime               int       `xml:"ampOnTime"`
	RetailMode              int       `xml:"retailMode"`
	Services                []Service `xml:"serviceList>service"`
	Devices                 []Device  `xml:"deviceList>device"`
}

type DirectControlAccountID

type DirectControlAccountID struct {
	Value string `xml:"val,attr"`
}

type DirectControlClientID

type DirectControlClientID struct {
	Value string `xml:"val,attr"`
}

type DirectControlIsSuspended

type DirectControlIsSuspended struct {
	Value string `xml:"val,attr"`
}

type EnqueuedTransportURI

type EnqueuedTransportURI struct {
	Value string `xml:"val,attr"`
}

type EnqueuedTransportURIMetaData

type EnqueuedTransportURIMetaData struct {
	Value string `xml:"val,attr"`
}

type EventHandlerFunc

type EventHandlerFunc func(interface{})

type EventZoneGroup

type EventZoneGroup struct {
	Coordinator     string                 `xml:"Coordinator,attr"`
	ID              string                 `xml:"ID,attr"`
	ZoneGroupMember []EventZoneGroupMember `xml:"ZoneGroupMember"`
}

type EventZoneGroupMember

type EventZoneGroupMember struct {
	UUID                    string `xml:"UUID,attr"`
	Location                string `xml:"Location,attr"`
	ZoneName                string `xml:"ZoneName,attr"`
	Icon                    string `xml:"Icon,attr"`
	Configuration           string `xml:"Configuration,attr"`
	SoftwareVersion         string `xml:"SoftwareVersion,attr"`
	SWGen                   string `xml:"SWGen,attr"`
	MinCompatibleVersion    string `xml:"MinCompatibleVersion,attr"`
	LegacyCompatibleVersion string `xml:"LegacyCompatibleVersion,attr"`
	ChannelMapSet           string `xml:"ChannelMapSet,attr"`
	BootSeq                 string `xml:"BootSeq,attr"`
	TVConfigurationError    string `xml:"TVConfigurationError,attr"`
	HdmiCecAvailable        string `xml:"HdmiCecAvailable,attr"`
	WirelessMode            string `xml:"WirelessMode,attr"`
	WirelessLeafOnly        string `xml:"WirelessLeafOnly,attr"`
	ChannelFreq             string `xml:"ChannelFreq,attr"`
	BehindWifiExtender      string `xml:"BehindWifiExtender,attr"`
	WifiEnabled             string `xml:"WifiEnabled,attr"`
	EthLink                 string `xml:"EthLink,attr"`
	Orientation             string `xml:"Orientation,attr"`
	RoomCalibrationState    string `xml:"RoomCalibrationState,attr"`
	SecureRegState          string `xml:"SecureRegState,attr"`
	VoiceConfigState        string `xml:"VoiceConfigState,attr"`
	MicEnabled              string `xml:"MicEnabled,attr"`
	AirPlayEnabled          string `xml:"AirPlayEnabled,attr"`
	IdleState               string `xml:"IdleState,attr"`
	MoreInfo                string `xml:"MoreInfo,attr"`
	SSLPort                 string `xml:"SSLPort,attr"`
	HHSSLPort               string `xml:"HHSSLPort,attr"`
	Invisible               string `xml:"Invisible,attr"`
	VirtualLineInSource     string `xml:"VirtualLineInSource,attr"`
}

type FoundZonePlayerFunc

type FoundZonePlayerFunc func(*Sonos, *ZonePlayer)

type Icon

type Icon struct {
	XMLName  xml.Name `xml:"icon"`
	ID       string   `xml:"id"`
	Mimetype string   `xml:"mimetype"`
	Width    int      `xml:"width"`
	Height   int      `xml:"height"`
	Depth    int      `xml:"depth"`
	URL      url.URL  `xml:"url"`
}

type Lite

type Lite struct {
	*didl.Lite
}

Lite embeds didl.Lite struct.

func NewDIDL

func NewDIDL() *Lite

NewDIDL returns a new Lite instance.

func ParseDIDL

func ParseDIDL(raw string) (*Lite, error)

ParseDIDL converts given raw string into Lite struct or otherwise returns an error.

type Loudness

type Loudness struct {
	Channel string `xml:"channel,attr"`
	Value   string `xml:"val,attr"`
}

type Mute

type Mute struct {
	Channel string `xml:"channel,attr"`
	Value   string `xml:"val,attr"`
}

type NextAVTransportURI

type NextAVTransportURI struct {
	Value string `xml:"val,attr"`
}

type NextAVTransportURIMetaData

type NextAVTransportURIMetaData struct {
	Value string `xml:"val,attr"`
}

type NextTrackMetaData

type NextTrackMetaData struct {
	Value string `xml:"val,attr"`
}

type NextTrackURI

type NextTrackURI struct {
	Value string `xml:"val,attr"`
}

type NumberOfTracks

type NumberOfTracks struct {
	Value string `xml:"val,attr"`
}

type OutputFixed

type OutputFixed struct {
	Value string `xml:"val,attr"`
}

type PlaybackStorageMedium

type PlaybackStorageMedium struct {
	Value string `xml:"val,attr"`
}

type PossiblePlaybackStorageMedia

type PossiblePlaybackStorageMedia struct {
	Value string `xml:"val,attr"`
}

type PossibleRecordQualityModes

type PossibleRecordQualityModes struct {
	Value string `xml:"val,attr"`
}

type PossibleRecordStorageMedia

type PossibleRecordStorageMedia struct {
	Value string `xml:"val,attr"`
}

type PresetNameList

type PresetNameList struct {
	Value string `xml:"val,attr"`
}

type QueueID

type QueueID struct {
	Value        string       `xml:"val,attr"`
	UpdateID     UpdateID     `xml:"UpdateID"`
	Curated      Curated      `xml:"Curated"`
	QueueOwnerID QueueOwnerID `xml:"QueueOwnerID"`
}

type QueueLastChange

type QueueLastChange struct {
	QueueID []QueueID `xml:"QueueID"`
}

func (*QueueLastChange) String

func (e *QueueLastChange) String() string

type QueueOwnerID

type QueueOwnerID struct {
	Value string `xml:"val,attr"`
}

type RecordMediumWriteStatus

type RecordMediumWriteStatus struct {
	Value string `xml:"val,attr"`
}

type RecordStorageMedium

type RecordStorageMedium struct {
	Value string `xml:"val,attr"`
}

type RenderingControlInstanceID

type RenderingControlInstanceID struct {
	Volume                    []Volume                  `xml:"Volume"`
	Mute                      []Mute                    `xml:"Mute"`
	Bass                      Bass                      `xml:"Bass"`
	Treble                    Treble                    `xml:"Treble"`
	Loudness                  Loudness                  `xml:"Loudness"`
	OutputFixed               OutputFixed               `xml:"OutputFixed"`
	SpeakerSize               SpeakerSize               `xml:"SpeakerSize"`
	SubGain                   SubGain                   `xml:"SubGain"`
	SubCrossover              SubCrossover              `xml:"SubCrossover"`
	SubPolarity               SubPolarity               `xml:"SubPolarity"`
	SubEnabled                SubEnabled                `xml:"SubEnabled"`
	SonarEnabled              SonarEnabled              `xml:"SonarEnabled"`
	SonarCalibrationAvailable SonarCalibrationAvailable `xml:"SonarCalibrationAvailable"`
	PresetNameList            PresetNameList            `xml:"PresetNameList"`
}

type RenderingControlLastChange

type RenderingControlLastChange struct {
	InstanceID RenderingControlInstanceID `xml:"InstanceID"`
}

http://upnp.org/specs/av/UPnP-av-RenderingControl-v1-Service.pdf

func (*RenderingControlLastChange) String

func (e *RenderingControlLastChange) String() string

type RestartPending

type RestartPending struct {
	Value string `xml:"val,attr"`
}

type Root

type Root struct {
	XMLName     xml.Name    `xml:"root"`
	Xmlns       string      `xml:"xmlns,attr"`
	SpecVersion SpecVersion `xml:"specVersion"`
	Device      Device      `xml:"device"`
}

type Satellite

type Satellite struct {
	XMLName                 xml.Name `xml:"Satellite"`
	UUID                    string   `xml:"UUID,attr"`
	Location                string   `xml:"Location,attr"`
	ZoneName                string   `xml:"ZoneName,attr"`
	Icon                    string   `xml:"Icon"`
	Configuration           string   `xml:"Configuration"`
	SoftwareVersion         string   `xml:"SoftwareVersion"`
	SWGen                   string   `xml:"SWGen"`
	MinCompatibleVersion    string   `xml:"MinCompatibleVersion"`
	LegacyCompatibleVersion string   `xml:"LegacyCompatibleVersion"`
	BootSeq                 string   `xml:"BootSeq"`
	TVConfigurationError    string   `xml:"TVConfigurationError"`
	HdmiCecAvailable        string   `xml:"HdmiCecAvailable"`
	WirelessMode            string   `xml:"WirelessMode"`
	WirelessLeafOnly        string   `xml:"WirelessLeafOnly"`
	HasConfiguredSSID       string   `xml:"HasConfiguredSSID"`
	ChannelFreq             string   `xml:"ChannelFreq"`
	BehindWifiExtender      string   `xml:"BehindWifiExtender"`
	WifiEnabled             string   `xml:"WifiEnabled"`
	Orientation             string   `xml:"Orientation"`
	RoomCalibrationState    string   `xml:"RoomCalibrationState"`
	SecureRegState          string   `xml:"SecureRegState"`
	VoiceConfigState        string   `xml:"VoiceConfigState"`
	MicEnabled              string   `xml:"MicEnabled"`
	AirPlayEnabled          string   `xml:"AirPlayEnabled"`
	IdleState               string   `xml:"IdleState"`
	MoreInfo                string   `xml:"MoreInfo"`
}

type Service

type Service struct {
	XMLName     xml.Name `xml:"service"`
	ServiceType string   `xml:"serviceType"`
	ServiceID   string   `xml:"serviceId"`
	ControlURL  string   `xml:"controlURL"`
	EventSubURL string   `xml:"eventSubURL"`
	SCPDURL     string   `xml:"SCPDURL"`
}

type Services

type Services struct {
	// services
	AlarmClock            *clk.Service
	AudioIn               *ain.Service
	AVTransport           *avt.Service
	ConnectionManager     *con.Service
	ContentDirectory      *dir.Service
	DeviceProperties      *dev.Service
	GroupManagement       *gmn.Service
	GroupRenderingControl *rcg.Service
	MusicServices         *mus.Service
	QPlay                 *ply.Service
	Queue                 *que.Service
	RenderingControl      *ren.Service
	SystemProperties      *sys.Service
	VirtualLineIn         *vli.Service
	ZoneGroupTopology     *zgt.Service
}

type SleepTimerGeneration

type SleepTimerGeneration struct {
	Value string `xml:"val,attr"`
}

type SnoozeRunning

type SnoozeRunning struct {
	Value string `xml:"val,attr"`
}

type SonarCalibrationAvailable

type SonarCalibrationAvailable struct {
	Value string `xml:"val,attr"`
}

type SonarEnabled

type SonarEnabled struct {
	Value string `xml:"val,attr"`
}

type Sonos

type Sonos struct {
	// contains filtered or unexported fields
}

func NewSonos

func NewSonos() (*Sonos, error)

func (*Sonos) Close

func (s *Sonos) Close()

func (*Sonos) FindRoom

func (s *Sonos) FindRoom(ctx context.Context, room string) (*ZonePlayer, error)

func (*Sonos) Register

func (s *Sonos) Register(zp *ZonePlayer) error

func (*Sonos) Renew

func (s *Sonos) Renew(ctx context.Context, opts *SubscriptionOptions) error

func (*Sonos) Search

func (s *Sonos) Search(ctx context.Context, fn FoundZonePlayerFunc) error

func (*Sonos) ServeHTTP

func (s *Sonos) ServeHTTP(response http.ResponseWriter, request *http.Request)

func (*Sonos) Subscribe

func (s *Sonos) Subscribe(ctx context.Context, opts *SubscriptionOptions) (string, error)

func (*Sonos) Unsubscribe

func (s *Sonos) Unsubscribe(ctx context.Context, opts *SubscriptionOptions) error

type SonosService

type SonosService interface {
	ControlEndpoint() *url.URL
	EventEndpoint() *url.URL
	ParseEvent([]byte) []interface{}
}

type SpeakerSize

type SpeakerSize struct {
	Value string `xml:"val,attr"`
}

type SpecVersion

type SpecVersion struct {
	XMLName xml.Name `xml:"specVersion"`
	Major   int      `xml:"major"`
	Minor   int      `xml:"minor"`
}

type SubCrossover

type SubCrossover struct {
	Value string `xml:"val,attr"`
}

type SubEnabled

type SubEnabled struct {
	Value string `xml:"val,attr"`
}

type SubGain

type SubGain struct {
	Value string `xml:"val,attr"`
}

type SubPolarity

type SubPolarity struct {
	Value string `xml:"val,attr"`
}

type SubscriptionOptions

type SubscriptionOptions struct {
	ZonePlayer *ZonePlayer
	Service    SonosService
	Timeout    uint64

	EventHandler EventHandlerFunc

	Sid string
}

func (*SubscriptionOptions) SetSid

func (o *SubscriptionOptions) SetSid(sid string)

func (*SubscriptionOptions) Validate

func (o *SubscriptionOptions) Validate() error

type TransportPlaySpeed

type TransportPlaySpeed struct {
	Value string `xml:"val,attr"`
}

type TransportState

type TransportState struct {
	Value string `xml:"val,attr"`
}

type TransportStatus

type TransportStatus struct {
	Value string `xml:"val,attr"`
}

type Treble

type Treble struct {
	Value string `xml:"val,attr"`
}

type UpdateID

type UpdateID struct {
	Value string `xml:"val,attr"`
}

type VanishedDevice

type VanishedDevice struct {
	XMLName                 xml.Name `xml:"VanishedDevice"`
	UUID                    string   `xml:"UUID,attr"`
	Location                string   `xml:"Location,attr"`
	ZoneName                string   `xml:"ZoneName,attr"`
	Icon                    string   `xml:"Icon"`
	Configuration           string   `xml:"Configuration"`
	SoftwareVersion         string   `xml:"SoftwareVersion,attr"`
	SWGen                   string   `xml:"SWGen"`
	MinCompatibleVersion    string   `xml:"MinCompatibleVersion"`
	LegacyCompatibleVersion string   `xml:"LegacyCompatibleVersion"`
	BootSeq                 string   `xml:"BootSeq"`
	TVConfigurationError    string   `xml:"TVConfigurationError"`
	HdmiCecAvailable        string   `xml:"HdmiCecAvailable"`
	WirelessMode            string   `xml:"WirelessMode"`
	WirelessLeafOnly        string   `xml:"WirelessLeafOnly"`
	HasConfiguredSSID       string   `xml:"HasConfiguredSSID"`
	ChannelFreq             string   `xml:"ChannelFreq"`
	BehindWifiExtender      string   `xml:"BehindWifiExtender"`
	WifiEnabled             string   `xml:"WifiEnabled"`
	Orientation             string   `xml:"Orientation"`
	RoomCalibrationState    string   `xml:"RoomCalibrationState"`
	SecureRegState          string   `xml:"SecureRegState"`
	VoiceConfigState        string   `xml:"VoiceConfigState"`
	MicEnabled              string   `xml:"MicEnabled"`
	AirPlayEnabled          string   `xml:"AirPlayEnabled"`
	IdleState               string   `xml:"IdleState"`
	MoreInfo                string   `xml:"MoreInfo"`
}

type Volume

type Volume struct {
	Channel string `xml:"channel,attr"`
	Value   string `xml:"val,attr"`
}

type ZoneGroup

type ZoneGroup struct {
	XMLName         xml.Name          `xml:"ZoneGroup"`
	Coordinator     string            `xml:"Coordinator,attr"`
	ID              string            `xml:"ID,attr"`
	ZoneGroupMember []ZoneGroupMember `xml:"ZoneGroupMember"`
}

type ZoneGroupMember

type ZoneGroupMember struct {
	XMLName                 xml.Name         `xml:"ZoneGroupMember"`
	UUID                    string           `xml:"UUID,attr"`
	Location                string           `xml:"Location,attr"`
	ZoneName                string           `xml:"ZoneName,attr"`
	Icon                    string           `xml:"Icon"`
	Configuration           string           `xml:"Configuration"`
	SoftwareVersion         string           `xml:"SoftwareVersion,attr"`
	SWGen                   string           `xml:"SWGen"`
	MinCompatibleVersion    string           `xml:"MinCompatibleVersion"`
	LegacyCompatibleVersion string           `xml:"LegacyCompatibleVersion"`
	BootSeq                 string           `xml:"BootSeq"`
	TVConfigurationError    string           `xml:"TVConfigurationError"`
	HdmiCecAvailable        string           `xml:"HdmiCecAvailable"`
	WirelessMode            string           `xml:"WirelessMode"`
	WirelessLeafOnly        string           `xml:"WirelessLeafOnly"`
	HasConfiguredSSID       string           `xml:"HasConfiguredSSID"`
	ChannelFreq             string           `xml:"ChannelFreq"`
	BehindWifiExtender      string           `xml:"BehindWifiExtender"`
	WifiEnabled             string           `xml:"WifiEnabled"`
	Orientation             string           `xml:"Orientation"`
	RoomCalibrationState    string           `xml:"RoomCalibrationState"`
	SecureRegState          string           `xml:"SecureRegState"`
	VoiceConfigState        string           `xml:"VoiceConfigState"`
	MicEnabled              string           `xml:"MicEnabled"`
	AirPlayEnabled          string           `xml:"AirPlayEnabled"`
	IdleState               string           `xml:"IdleState"`
	MoreInfo                string           `xml:"MoreInfo"`
	Satellite               []Satellite      `xml:"Satellite"`
	VanishedDevice          []VanishedDevice `xml:"VanishedDevices>VanishedDevice"`
}

type ZoneGroupState

type ZoneGroupState struct {
	XMLName    xml.Name    `xml:"ZoneGroupState"`
	ZoneGroups []ZoneGroup `xml:"ZoneGroups>ZoneGroup"`
}

type ZoneGroupTopologyAvailableSoftwareUpdate

type ZoneGroupTopologyAvailableSoftwareUpdate struct {
	Type             string `xml:"Type,attr"`
	Version          string `xml:"Version,attr"`
	UpdateURL        string `xml:"UpdateURL,attr"`
	DownloadSize     string `xml:"DownloadSize,attr"`
	ManifestURL      string `xml:"ManifestURL,attr"`
	Swgen            string `xml:"Swgen,attr"`
	LatestSwgen      string `xml:"LatestSwgen,attr"`
	ManifestRevision string `xml:"ManifestRevision,attr"`
}

func (*ZoneGroupTopologyAvailableSoftwareUpdate) String

type ZoneGroupTopologyZoneGroupState

type ZoneGroupTopologyZoneGroupState struct {
	ZoneGroups      ZoneGroups `xml:"ZoneGroups"`
	VanishedDevices string     `xml:"VanishedDevices"`
}

func (*ZoneGroupTopologyZoneGroupState) String

type ZoneGroups

type ZoneGroups struct {
	ZoneGroup []ZoneGroup `xml:"ZoneGroup"`
}

type ZonePlayer

type ZonePlayer struct {
	Root *Root

	*Services
	// contains filtered or unexported fields
}

func NewZonePlayer

func NewZonePlayer(opts ...ZonePlayerOption) (*ZonePlayer, error)

NewZonePlayer returns a new ZonePlayer instance.

func (*ZonePlayer) Client

func (z *ZonePlayer) Client() *http.Client

Client returns the underlying http client.

func (*ZonePlayer) Event

func (zp *ZonePlayer) Event(evt interface{}, fn EventHandlerFunc)

Event processes incoming UPnP events and dispatches them to the registered event handler. It handles complex events (LastChange, ZoneGroupState) by unmarshalling their XML payload, and simple events by passing the typed value directly.

Handled Services:

  • AVTransport (LastChange)
  • RenderingControl (LastChange)
  • Queue (LastChange)
  • ZoneGroupTopology (AvailableSoftwareUpdate, ZoneGroupState, etc.)
  • AlarmClock
  • AudioIn
  • ConnectionManager
  • ContentDirectory
  • DeviceProperties
  • GroupManagement
  • GroupRenderingControl
  • MusicServices
  • SystemProperties
  • VirtualLineIn

func (*ZonePlayer) GetAudioInputAttributes

func (z *ZonePlayer) GetAudioInputAttributes() (*ain.GetAudioInputAttributesResponse, error)

func (*ZonePlayer) GetGroupVolume

func (z *ZonePlayer) GetGroupVolume() (int, error)

func (*ZonePlayer) GetLineInLevel

func (z *ZonePlayer) GetLineInLevel() (*ain.GetLineInLevelResponse, error)

func (*ZonePlayer) GetPositionInfo

func (z *ZonePlayer) GetPositionInfo() (*avt.GetPositionInfoResponse, error)

func (*ZonePlayer) GetVolume

func (z *ZonePlayer) GetVolume() (int, error)

func (*ZonePlayer) GetZoneGroupAttributes

func (z *ZonePlayer) GetZoneGroupAttributes() (*zgt.GetZoneGroupAttributesResponse, error)

func (*ZonePlayer) GetZoneGroupState

func (z *ZonePlayer) GetZoneGroupState() (*ZoneGroupState, error)

func (*ZonePlayer) GetZoneInfo

func (z *ZonePlayer) GetZoneInfo() (*dev.GetZoneInfoResponse, error)

func (*ZonePlayer) HardwareVersion

func (z *ZonePlayer) HardwareVersion() string

func (*ZonePlayer) IsCoordinator

func (z *ZonePlayer) IsCoordinator() bool

func (*ZonePlayer) IsMuted

func (z *ZonePlayer) IsMuted() (bool, error)

func (*ZonePlayer) ListQueue

func (z *ZonePlayer) ListQueue() ([]didl.Item, error)

func (*ZonePlayer) Location

func (z *ZonePlayer) Location() *url.URL

func (*ZonePlayer) MACAddress

func (z *ZonePlayer) MACAddress() string

func (*ZonePlayer) ModelDescription

func (z *ZonePlayer) ModelDescription() string

func (*ZonePlayer) ModelName

func (z *ZonePlayer) ModelName() string

func (*ZonePlayer) Mute

func (z *ZonePlayer) Mute() error

func (*ZonePlayer) Next

func (z *ZonePlayer) Next() error

func (*ZonePlayer) Pause

func (z *ZonePlayer) Pause() error

func (*ZonePlayer) Play

func (z *ZonePlayer) Play() error

func (*ZonePlayer) Previous

func (z *ZonePlayer) Previous() error

func (*ZonePlayer) RoomName

func (z *ZonePlayer) RoomName() string

func (*ZonePlayer) SelectAudio

func (z *ZonePlayer) SelectAudio(objectID string) error

func (*ZonePlayer) SerialNumber

func (z *ZonePlayer) SerialNumber() string

func (*ZonePlayer) SetAVTransportURI

func (z *ZonePlayer) SetAVTransportURI(url string) error

func (*ZonePlayer) SetAudioInputAttributes

func (z *ZonePlayer) SetAudioInputAttributes(desiredName, desiredIcon string) error

func (*ZonePlayer) SetGroupVolume

func (z *ZonePlayer) SetGroupVolume(desiredVolume int) error

func (*ZonePlayer) SetLineInLevel

func (z *ZonePlayer) SetLineInLevel(desiredLeftLineInLevel, desiredRightLineInLevel int32) error

func (*ZonePlayer) SetVolume

func (z *ZonePlayer) SetVolume(desiredVolume int) error

func (*ZonePlayer) SoftwareVersion

func (z *ZonePlayer) SoftwareVersion() string

func (*ZonePlayer) Stop

func (z *ZonePlayer) Stop() error

func (*ZonePlayer) SwitchToLineIn

func (z *ZonePlayer) SwitchToLineIn() error

func (*ZonePlayer) SwitchToQueue

func (z *ZonePlayer) SwitchToQueue() error

func (*ZonePlayer) UUID

func (z *ZonePlayer) UUID() string

func (*ZonePlayer) Unmute

func (z *ZonePlayer) Unmute() error

type ZonePlayerOption

type ZonePlayerOption func(*ZonePlayer)

func WithClient

func WithClient(c *http.Client) ZonePlayerOption

func WithLocation

func WithLocation(u *url.URL) ZonePlayerOption

Directories

Path Synopsis
cmd
makeservices command
A minimal implementation of the Digital Item Declaration Language (DIDL).
A minimal implementation of the Digital Item Declaration Language (DIDL).
examples
lssonos command
play command
sub command
services
AVTransport
Package avtransport is a generated AVTransport package.
Package avtransport is a generated AVTransport package.
AlarmClock
Package alarmclock is a generated AlarmClock package.
Package alarmclock is a generated AlarmClock package.
AudioIn
Package audioin is a generated AudioIn package.
Package audioin is a generated AudioIn package.
ConnectionManager
Package connectionmanager is a generated ConnectionManager package.
Package connectionmanager is a generated ConnectionManager package.
ContentDirectory
Package contentdirectory is a generated ContentDirectory package.
Package contentdirectory is a generated ContentDirectory package.
DeviceProperties
Package deviceproperties is a generated DeviceProperties package.
Package deviceproperties is a generated DeviceProperties package.
GroupManagement
Package groupmanagement is a generated GroupManagement package.
Package groupmanagement is a generated GroupManagement package.
GroupRenderingControl
Package grouprenderingcontrol is a generated GroupRenderingControl package.
Package grouprenderingcontrol is a generated GroupRenderingControl package.
MusicServices
Package musicservices is a generated MusicServices package.
Package musicservices is a generated MusicServices package.
QPlay
Package qplay is a generated QPlay package.
Package qplay is a generated QPlay package.
Queue
Package queue is a generated Queue package.
Package queue is a generated Queue package.
RenderingControl
Package renderingcontrol is a generated RenderingControl package.
Package renderingcontrol is a generated RenderingControl package.
SystemProperties
Package systemproperties is a generated SystemProperties package.
Package systemproperties is a generated SystemProperties package.
VirtualLineIn
Package virtuallinein is a generated VirtualLineIn package.
Package virtuallinein is a generated VirtualLineIn package.
ZoneGroupTopology
Package zonegrouptopology is a generated ZoneGroupTopology package.
Package zonegrouptopology is a generated ZoneGroupTopology package.

Jump to

Keyboard shortcuts

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