playback

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataStorage

func DataStorage(t MsgType) (interface{}, error)

Types

type AudioInfo

type AudioInfo struct {
	SampleRate int
	Codec      uint
	Duration   time.Duration
}

type MsgType

type MsgType int
const (
	RegistrationT MsgType = iota
	PlaybackRequestT
	NewStateT
	SeekCmdT
	StopCmdT
	PauseCmdT
	ResumeCmdT
	SetVolCmdT
	UnknownT
)

func DataMsgType

func DataMsgType(data interface{}) (MsgType, error)

func (MsgType) String

func (t MsgType) String() string

type PauseCmd

type PauseCmd struct{}

type Playback

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

func Init

func Init(logger *slog.Logger) *Playback

func (*Playback) AddReceiver

func (p *Playback) AddReceiver(r Receiver)

func (*Playback) CommCh

func (p *Playback) CommCh() chan comm

func (*Playback) Pause

func (p *Playback) Pause(playerName string) error

func (*Playback) Play

func (p *Playback) Play(playerName string, url string) error

func (*Playback) Resume

func (p *Playback) Resume(playerName string) error

func (*Playback) Run

func (p *Playback) Run(ctx context.Context) error

func (*Playback) Seek

func (p *Playback) Seek(playerName string, pos int) error

func (*Playback) SetVol

func (p *Playback) SetVol(playerName string, vol int) error

func (*Playback) Stop

func (p *Playback) Stop(playerName string) error

type PlaybackRequest

type PlaybackRequest struct {
	URL string
}

type PlaybackState

type PlaybackState struct {
	Status       PlaybackStatus
	EndReached   bool
	LastPosition int
	Since        time.Time
}

type PlaybackStatus

type PlaybackStatus int
const (
	Stopped PlaybackStatus = iota
	Requested
	Error
	Paused
	Playing
)

func (PlaybackStatus) String

func (s PlaybackStatus) String() string

type PlayerMsg

type PlayerMsg struct {
	MsgType MsgType
	Data    json.RawMessage
}

type Receiver

type Receiver interface {
	Run(ctx context.Context) error
	HandleUpdates(map[string]*State)
}

type Registration

type Registration struct {
	Name string
}

type ResumeCmd

type ResumeCmd struct{}

type SeekCmd

type SeekCmd struct {
	Position int
}

type SetVolCmd

type SetVolCmd struct {
	Volume int
}

type State

type State struct {
	Volume          int
	DeviceAvailable bool
	AudioInfo       AudioInfo
	Playback        PlaybackState
}

type StopCmd

type StopCmd struct{}

Jump to

Keyboard shortcuts

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