playback

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: AGPL-3.0 Imports: 8 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 InitPlayerF added in v0.2.0

type InitPlayerF func(newStateCB NewStateCB, opts ...PlayerOption) (*Player, error)

type MsgType

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

func DataMsgType

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

func (MsgType) String

func (m MsgType) String() string

type NewPlayerCB added in v0.2.0

type NewPlayerCB func(ctx context.Context, initF InitPlayerF) error

type NewStateCB added in v0.2.0

type NewStateCB func(old, new PlayerState) error

type PauseCmd

type PauseCmd struct{}

type PlayCmd added in v0.2.0

type PlayCmd struct {
	URL string
}

type Playback

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

func Init

func Init(listen string, port int, newPlayerCB NewPlayerCB, opts ...PlaybackOption) (*Playback, error)

func (*Playback) Run

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

type PlaybackOption added in v0.2.1

type PlaybackOption func(*Playback)

func PlaybackWithLogger added in v0.2.1

func PlaybackWithLogger(logger *slog.Logger) PlaybackOption

func PlaybackWithTcpOpts added in v0.2.1

func PlaybackWithTcpOpts(opts ...tcp.ServerOption) PlaybackOption

type PlaybackStatus

type PlaybackStatus int
const (
	Stopped PlaybackStatus = iota
	EndReached
	Paused
	Playing
)

func (PlaybackStatus) String

func (p PlaybackStatus) String() string

type Player added in v0.2.0

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

func (*Player) Pause added in v0.2.0

func (p *Player) Pause() error

func (*Player) Play added in v0.2.0

func (p *Player) Play(url string) error

func (*Player) Resume added in v0.2.0

func (p *Player) Resume() error

func (*Player) Run added in v0.2.0

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

func (*Player) Seek added in v0.2.0

func (p *Player) Seek(pos time.Duration) error

func (*Player) SetVol added in v0.2.0

func (p *Player) SetVol(vol int) error

func (*Player) State added in v0.2.0

func (p *Player) State() PlayerState

func (*Player) Stop added in v0.2.0

func (p *Player) Stop() error

type PlayerMsg

type PlayerMsg struct {
	MsgType MsgType
	Data    json.RawMessage
}

type PlayerOption added in v0.2.1

type PlayerOption func(*Player)

func PlayerWithCommOpts added in v0.2.1

func PlayerWithCommOpts(opts ...tcp.CommOption) PlayerOption

func PlayerWithLogger added in v0.2.1

func PlayerWithLogger(logger *slog.Logger) PlayerOption

func PlayerWithLoggerWith added in v0.2.1

func PlayerWithLoggerWith(args ...any) PlayerOption

type PlayerState added in v0.2.0

type PlayerState struct {
	Name     string
	Volume   int
	Status   PlaybackStatus
	Duration time.Duration
	Elapsed  time.Duration
	Since    time.Time
}

func (*PlayerState) Equal added in v0.4.1

func (p *PlayerState) Equal(cmp PlayerState) bool

func (*PlayerState) PlaybackActive added in v0.4.1

func (p *PlayerState) PlaybackActive() bool

type ResumeCmd

type ResumeCmd struct{}

type SeekCmd

type SeekCmd struct {
	Position time.Duration
}

type SetNameCmd added in v0.2.0

type SetNameCmd struct {
	Name string
}

type SetVolCmd

type SetVolCmd struct {
	Volume int
}

type StopCmd

type StopCmd struct{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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