added player stuff
This commit is contained in:
@@ -12,10 +12,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Player struct {
|
type Player struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
state PlayerState
|
state PlayerState
|
||||||
streamer beep.Streamer
|
streamer beep.Streamer
|
||||||
format beep.Format
|
format beep.Format
|
||||||
|
sampleRate beep.SampleRate
|
||||||
}
|
}
|
||||||
|
|
||||||
type PlayerState int
|
type PlayerState int
|
||||||
@@ -26,13 +27,18 @@ const (
|
|||||||
Stopped
|
Stopped
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewPlayer() (*Player, error) {
|
func NewPlayer() *Player {
|
||||||
return &Player{}, nil
|
return &Player{
|
||||||
|
// TODO: variable speaker sample rates
|
||||||
|
sampleRate: beep.SampleRate(44100),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) Init(ctx context.Context) {
|
func (p *Player) Init(ctx context.Context) {
|
||||||
p.ctx = ctx
|
p.ctx = ctx
|
||||||
p.state = Stopped
|
p.state = Stopped
|
||||||
|
|
||||||
|
speaker.Init(p.sampleRate, p.sampleRate.N(time.Second/10))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) ChangeState(desiredState PlayerState) error {
|
func (p *Player) ChangeState(desiredState PlayerState) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user