state

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const AudioSourceInternetRadio = "Internet radio"

Variables

This section is empty.

Functions

func NormalizeVolume

func NormalizeVolume(volume int) int

func ParsePresetsCount

func ParsePresetsCount(presetsCount int) (int, error)

func ValidAudioSource

func ValidAudioSource(s *State, audioSource string) error

func ValidPresetNumber

func ValidPresetNumber(s *State, preset int) error

Types

type Changed

type Changed int
const (
	ChangedNone                = 0
	ChangedAudioSource Changed = 1 << iota
	ChangedIsMuted
	ChangedMetadata
	ChangedPower
	ChangedPresetNumber
	ChangedPresets
	ChangedStatus
	ChangedTitle
	ChangedTitleNew
	ChangedURL
	ChangedURLNew
	ChangedUUID
	ChangedVolume
)
const ChangedAll Changed = math.MaxInt

func (Changed) Is

func (c Changed) Is(check Changed) bool

func (Changed) Merge

func (c Changed) Merge(merge Changed) Changed

type Partial

type Partial struct {
	AudioSource  *string  `json:"audio_source,omitempty"`
	IsMuted      *bool    `json:"is_muted,omitempty"`
	Metadata     *string  `json:"metadata,omitempty"`
	Power        *bool    `json:"power,omitempty"`
	PresetNumber *int     `json:"preset_number,omitempty"`
	Presets      []Preset `json:"presets,omitempty"`
	Status       *Status  `json:"status,omitempty"`
	Title        *string  `json:"title,omitempty"`
	TitleNew     *string  `json:"title_new,omitempty"`
	URL          *string  `json:"url,omitempty"`
	URLNew       *string  `json:"url_new,omitempty"`
	UUID         string   `json:"uuid"`
	Volume       *int     `json:"volume,omitempty"`
}

func GetPartial

func GetPartial(s *State, c Changed) Partial

func NewPartial

func NewPartial(uuid string) Partial

type Preset

type Preset struct {
	Number   int    `json:"number" validate:"required"`    // Number is the preset number.
	Title    string `json:"title" validate:"required"`     // Title of the preset.
	TitleNew string `json:"title_new" validate:"required"` // TitleNew is the overridden title.
	URL      string `json:"url" validate:"required"`       // URL of the preset.
	URLNew   string `json:"url_new" validate:"required"`   // URLNew is the overridden URL.

} //	@name	state.Preset

func NewPreset

func NewPreset(number int, title, url string) Preset

type State

type State struct {
	AudioSource  string   `json:"audio_source" validate:"required"`  // AudioSource is the audio source.
	AudioSources []string `json:"audio_sources" validate:"required"` // AudioSources is the list of available audio sources.
	IsMuted      bool     `json:"is_muted" validate:"required"`      // IsMuted represents if the radio is muted.
	Metadata     string   `json:"metadata" validate:"required"`      // Metadata of the current playing stream.
	ModelName    string   `json:"model_name" validate:"required"`    // ModelName is the model name of the device.
	ModelNumber  string   `json:"model_number" validate:"required"`  // ModelNumber is the model number of the device.
	Name         string   `json:"name" validate:"required"`          // Name of the radio.
	Power        bool     `json:"power" validate:"required"`         // Power represents if the radio is not in standby.
	PresetNumber int      `json:"preset_number" validate:"required"` // PresetNumber is the current preset that is playing.
	Presets      []Preset `json:"presets" validate:"required"`       // Presets of the radio.
	Status       Status   `json:"status" validate:"required"`        // Status is either playing, connecting, or stopped.
	Title        string   `json:"title" validate:"required"`         // Title of the current playing stream.
	TitleNew     string   `json:"title_new" validate:"required"`     // TitleNew is the overridden title.
	URL          string   `json:"url" validate:"required"`           // URL of the stream that is currently selected.
	URLNew       string   `json:"url_new" validate:"required"`       // URLNew is the overridden URL.
	UUID         string   `json:"uuid" validate:"required"`          // UUID of the radio.
	Volume       int      `json:"volume" validate:"required"`        // Volume of the radio.

} //	@name	state.State

func New

func New(uuid, name, modelName, modelNumber string, audioSources []string) State

func (*State) SetAudioSource

func (s *State) SetAudioSource(audioSource string) (Changed, error)

func (*State) SetIsMuted

func (s *State) SetIsMuted(isMuted bool) Changed

func (*State) SetMetadata

func (s *State) SetMetadata(metadata string) Changed

func (*State) SetPower

func (s *State) SetPower(power bool) Changed

func (*State) SetPresets

func (s *State) SetPresets(presets []Preset) Changed

func (*State) SetStatus

func (s *State) SetStatus(status Status) Changed

func (*State) SetTitle

func (s *State) SetTitle(title string) Changed

func (*State) SetTitleNew

func (s *State) SetTitleNew(titleNew string) Changed

func (*State) SetURL

func (s *State) SetURL(url string) Changed

func (*State) SetURLNew

func (s *State) SetURLNew(urlNew string) Changed

func (*State) SetVolume

func (s *State) SetVolume(volume int) Changed

type Status

type Status string
const (
	StatusConnecting Status = "Connecting"
	StatusPlaying    Status = "Playing"
	StatusStopped    Status = "Stopped"
	StatusUnknown    Status = ""
)

func ParseStatus

func ParseStatus(status string) Status

Jump to

Keyboard shortcuts

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