snapcast

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseResult

func ParseResult[T any](result interface{}) (*T, error)

Types

type Client

type Client struct {
	Config struct {
		Instance int    `json:"instance"`
		Latency  int    `json:"latency"`
		Name     string `json:"name"`
		Volume   Volume `json:"volume"`
	} `json:"config"`
	Connected bool `json:"connected"`
	Host      struct {
		Arch string `json:"arch"`
		IP   string `json:"ip"`
		MAC  string `json:"mac"`
		Name string `json:"name"`
		OS   string `json:"os"`
	} `json:"host"`
	ID       string `json:"id"`
	LastSeen struct {
		Sec  int `json:"sec"`
		USec int `json:"usec"`
	} `json:"lastSeen"`
	Snapclient struct {
		Name            string `json:"name"`
		ProtocolVersion int    `json:"protocolVersion"`
		Version         string `json:"version"`
	} `json:"snapclient"`
}

type ClientGetStatusRequest

type ClientGetStatusRequest struct {
	ID string `json:"id"`
}

Request Response

type ClientGetStatusResponse

type ClientGetStatusResponse struct {
	Client Client `json:"client"`
}

Request Response

type ClientOnConnect

type ClientOnConnect struct {
	Client *Client `json:"client"`
	ID     string  `json:"id"`
}

Notifications

type ClientOnDisconnect

type ClientOnDisconnect struct {
	Client *Client `json:"client"`
	ID     string  `json:"id"`
}

Notifications

type ClientOnLatencyChanged

type ClientOnLatencyChanged struct {
	Latency int    `json:"latency"`
	ID      string `json:"id"`
}

Notifications

type ClientOnNameChanged

type ClientOnNameChanged struct {
	Name string `json:"name"`
	ID   string `json:"id"`
}

Notifications

type ClientOnVolumeChanged

type ClientOnVolumeChanged struct {
	Volume Volume `json:"volume"`
	ID     string `json:"id"`
}

Notifications

type ClientSetLatencyRequest

type ClientSetLatencyRequest struct {
	ID      string `json:"id"`
	Latency int    `json:"latency"`
}

Request Response

type ClientSetLatencyResponse

type ClientSetLatencyResponse struct {
	Latency int `json:"latency"`
}

Request Response

type ClientSetNameRequest

type ClientSetNameRequest struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Request Response

type ClientSetNameResponse

type ClientSetNameResponse struct {
	Name string `json:"name"`
}

Request Response

type ClientSetVolumeRequest

type ClientSetVolumeRequest struct {
	ID     string `json:"id"`
	Volume Volume `json:"volume"`
}

Request Response

type ClientSetVolumeResponse

type ClientSetVolumeResponse struct {
	Volume Volume `json:"volume"`
}

Request Response

type Error

type Error struct {
	Code    int         `json:"code,omitempty"`
	Data    interface{} `json:"data,omitempty"`
	Message string      `json:"message,omitempty"`
}

type Group

type Group struct {
	Clients  []Client `json:"clients"`
	ID       string   `json:"id"`
	Muted    bool     `json:"muted"`
	Name     string   `json:"name"`
	StreamID string   `json:"stream_id"`
}

type GroupGetStatusRequest

type GroupGetStatusRequest struct {
	ID string `json:"id"`
}

Request Response

type GroupGetStatusResponse

type GroupGetStatusResponse struct {
	Group Group `json:"group"`
}

Request Response

type GroupOnMute

type GroupOnMute struct {
	Mute bool   `json:"mute"`
	ID   string `json:"id"`
}

Notifications

type GroupOnNameChanged

type GroupOnNameChanged struct {
	Name string `json:"name"`
	ID   string `json:"id"`
}

Notifications

type GroupOnStreamChanged

type GroupOnStreamChanged struct {
	ID       string `json:"id"`
	StreamId string `json:"stream_id"`
}

Notifications

type GroupSetClientsRequest

type GroupSetClientsRequest struct {
	ID      string   `json:"id"`
	Clients []string `json:"clients"`
}

Request Response

type GroupSetClientsResponse

type GroupSetClientsResponse struct {
	Clients []*Client `json:"clients"`
}

Request Response

type GroupSetMuteRequest

type GroupSetMuteRequest struct {
	ID    string `json:"id"`
	Muted bool   `json:"muted"`
}

Request Response

type GroupSetMuteResponse

type GroupSetMuteResponse struct {
	Muted bool `json:"muted"`
}

Request Response

type GroupSetNameRequest

type GroupSetNameRequest struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Request Response

type GroupSetNameResponse

type GroupSetNameResponse struct {
	Name string `json:"name"`
}

Request Response

type GroupSetStreamRequest

type GroupSetStreamRequest struct {
	ID       string `json:"id"`
	StreamID string `json:"stream_id"`
}

Request Response

type GroupSetStreamResponse

type GroupSetStreamResponse struct {
	StreamID string `json:"stream_id"`
}

Request Response

type LoopStatus

type LoopStatus string
const (
	LoopNone     LoopStatus = "none"
	LoopTrack    LoopStatus = "track"
	LoopPlaylist LoopStatus = "playlist"
)

type Metadata

type Metadata struct {
	TrackID     string   `json:"trackId,omitempty"`
	Title       string   `json:"title,omitempty"`
	Artist      []string `json:"artist,omitempty"`
	Album       string   `json:"album,omitempty"`
	AlbumArtist []string `json:"albumArtist,omitempty"`
	Genre       []string `json:"genre,omitempty"`
	Duration    float64  `json:"duration,omitempty"`
	TrackNumber int      `json:"trackNumber,omitempty"`
	DiscNumber  int      `json:"discNumber,omitempty"`
	Date        string   `json:"date,omitempty"`
	ArtURL      string   `json:"artUrl,omitempty"`
	URL         string   `json:"url,omitempty"`
}

type Notification

type Notification struct {
	ID         *int                `json:"id,omitempty"`
	JsonRPC    string              `json:"jsonrpc,omitempty"`
	Method     *NotificationMethod `json:"method,omitempty"`
	Params     interface{}         `json:"params,omitempty"`
	ReceivedAt time.Time           `json:"-"`
}

type NotificationMethod

type NotificationMethod string
const (
	// Client
	MethodClientOnConnect        NotificationMethod = "Client.OnConnect"
	MethodClientOnDisconnect     NotificationMethod = "Client.OnDisconnect"
	MethodClientOnVolumeChanged  NotificationMethod = "Client.OnVolumeChanged"
	MethodClientOnLatencyChanged NotificationMethod = "Client.OnLatencyChanged"
	MethodClientOnNameChanged    NotificationMethod = "Client.OnNameChanged"

	// Group
	MethodGroupOnMute          NotificationMethod = "Group.OnMute"
	MethodGroupOnStreamChanged NotificationMethod = "Group.OnStreamChanged"
	MethodGroupOnNameChanged   NotificationMethod = "Group.OnNameChanged"

	// Stream
	MethodStreamOnProperties NotificationMethod = "Stream.OnProperties"
	MethodStreamOnUpdate     NotificationMethod = "Stream.OnUpdate"

	// Server
	MethodServerOnUpdate NotificationMethod = "Server.OnUpdate"
)

Notifications

type PlaybackStatus

type PlaybackStatus string
const (
	PlaybackPlaying PlaybackStatus = "playing"
	PlaybackPaused  PlaybackStatus = "paused"
	PlaybackStopped PlaybackStatus = "stopped"
)

type Properties

type Properties struct {
	PlaybackStatus PlaybackStatus `json:"playbackStatus,omitempty"`
	LoopStatus     LoopStatus     `json:"loopStatus,omitempty"`
	Shuffle        bool           `json:"shuffle,omitempty"`
	Volume         int            `json:"volume,omitempty"`
	Mute           bool           `json:"mute,omitempty"`
	Rate           float64        `json:"rate,omitempty"`
	Position       float64        `json:"position,omitempty"`
	CanGoNext      bool           `json:"canGoNext,omitempty"`
	CanGoPrevious  bool           `json:"canGoPrevious,omitempty"`
	CanPlay        bool           `json:"canPlay,omitempty"`
	CanPause       bool           `json:"canPause,omitempty"`
	CanSeek        bool           `json:"canSeek,omitempty"`
	CanControl     bool           `json:"canControl,omitempty"`
	Metadata       *Metadata      `json:"metadata,omitempty"`
}

type Request

type Request struct {
	ID      *int           `json:"id,omitempty"`
	JsonRPC string         `json:"jsonrpc,omitempty"`
	Method  *RequestMethod `json:"method,omitempty"`
	Params  interface{}    `json:"params,omitempty"`
}

type RequestMethod

type RequestMethod string
const (
	// Client
	MethodClientGetStatus  RequestMethod = "Client.GetStatus"
	MethodClientSetVolume  RequestMethod = "Client.SetVolume"
	MethodClientSetLatency RequestMethod = "Client.SetLatency"
	MethodClientSetName    RequestMethod = "Client.SetName"

	// Group
	MethodGroupGetStatus  RequestMethod = "Group.GetStatus"
	MethodGroupSetMute    RequestMethod = "Group.SetMute"
	MethodGroupSetStream  RequestMethod = "Group.SetStream"
	MethodGroupSetClients RequestMethod = "Group.SetClients"
	MethodGroupSetName    RequestMethod = "Group.SetName"

	// Server
	MethodServerGetRPCVersion RequestMethod = "Server.GetRPCVersion"
	MethodServerGetStatus     RequestMethod = "Server.GetStatus"
	MethodServerDeleteClient  RequestMethod = "Server.DeleteClient"

	// Stream
	MethodStreamAddStream    RequestMethod = "Stream.AddStream"
	MethodStreamRemoveStream RequestMethod = "Stream.RemoveStream"
	MethodStreamControl      RequestMethod = "Stream.Control"
	MethodStreamSetProperty  RequestMethod = "Stream.SetProperty"
)

Requests

type Response

type Response struct {
	ID         *int        `json:"id,omitempty"`
	JsonRPC    string      `json:"jsonrpc,omitempty"`
	Error      *Error      `json:"error,omitempty"`
	Result     interface{} `json:"result,omitempty"`
	ReceivedAt time.Time   `json:"-"`
}

type Server

type Server struct {
	Groups []Group `json:"groups"`
	Host   struct {
		Arch string `json:"arch"`
		IP   string `json:"ip"`
		MAC  string `json:"mac"`
		Name string `json:"name"`
		OS   string `json:"os"`
	} `json:"host"`
	Snapserver Snapserver `json:"snapserver"`
	Streams    []Stream   `json:"streams"`
}

type ServerDeleteClient

type ServerDeleteClient struct {
	ID string `json:"id"`
}

Request Response

type ServerDeleteClientResponse

type ServerDeleteClientResponse struct {
	Server Server `json:"server"`
}

Request Response

type ServerGetRPCVersion

type ServerGetRPCVersion struct{}

Request Response

type ServerGetRPCVersionResponse

type ServerGetRPCVersionResponse struct {
	Major int `json:"major"`
	Minor int `json:"minor"`
	Patch int `json:"patch"`
}

Request Response

type ServerGetStatusRequest

type ServerGetStatusRequest struct{}

Request Response

type ServerGetStatusResponse

type ServerGetStatusResponse struct {
	Server Server `json:"server"`
}

Request Response

type ServerOnUpdate

type ServerOnUpdate struct {
	Server Server `json:"server"`
}

Notifications

type Snapserver

type Snapserver struct {
	ControlProtocolVersion int    `json:"controlProtocolVersion"`
	Name                   string `json:"name"`
	ProtocolVersion        int    `json:"protocolVersion"`
	Version                string `json:"version"`
}

type Stream

type Stream struct {
	ID     string       `json:"id"`
	Status StreamStatus `json:"status"`
	URI    struct {
		Fragment string            `json:"fragment"`
		Host     string            `json:"host"`
		Path     string            `json:"path"`
		Query    map[string]string `json:"query"`
		Raw      string            `json:"raw"`
		Scheme   string            `json:"scheme"`
	} `json:"uri"`
	Properties *Properties `json:"properties,omitempty"`
}

type StreamAddStream

type StreamAddStream struct {
	StreamUri string `json:"streamUri"`
}

Request Response

type StreamAddStreamResponse

type StreamAddStreamResponse struct {
	StreamId string `json:"stream_id"`
}

Request Response

type StreamCommand

type StreamCommand string
const (
	StreamCommandNext        StreamCommand = "next"
	StreamCommandPrevious    StreamCommand = "previous"
	StreamCommandPlay        StreamCommand = "play"
	StreamCommandPause       StreamCommand = "pause"
	StreamCommandPlayPause   StreamCommand = "playPause"
	StreamCommandStop        StreamCommand = "stop"
	StreamCommandSeek        StreamCommand = "seek"
	StreamCommandSetPosition StreamCommand = "setPosition"
)

type StreamControl

type StreamControl struct {
	ID      string        `json:"id"`
	Command StreamCommand `json:"command"`
	Params  interface{}   `json:"params,omitempty"`
}

Request Response

type StreamControlResponse

type StreamControlResponse string

Request Response

type StreamOnProperties

type StreamOnProperties struct {
	ID         string     `json:"id"`
	Properties Properties `json:"properties"`
}

Notifications

type StreamOnUpdate

type StreamOnUpdate struct {
	ID     string `json:"id"`
	Stream Stream `json:"stream"`
}

Notifications

type StreamRemoveStream

type StreamRemoveStream struct {
	ID string `json:"id"`
}

Request Response

type StreamRemoveStreamResponse

type StreamRemoveStreamResponse struct {
	StreamId string `json:"stream_id"`
}

Request Response

type StreamSetProperty

type StreamSetProperty struct {
	ID       string      `json:"id"`
	Property string      `json:"property"`
	Value    interface{} `json:"value"`
}

Request Response

type StreamSetPropertyResponse

type StreamSetPropertyResponse string

Request Response

type StreamStatus

type StreamStatus string
const (
	StreamIdle    StreamStatus = "idle"
	StreamPlaying StreamStatus = "playing"
)

func (StreamStatus) IsIdle

func (s StreamStatus) IsIdle() bool

func (StreamStatus) IsPlaying

func (s StreamStatus) IsPlaying() bool

type Volume

type Volume struct {
	Muted   bool `json:"muted"`
	Percent int  `json:"percent"`
}

Jump to

Keyboard shortcuts

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