audio/internal/go2cpp: Add readerDriverPlayer.Reset

This commit is contained in:
Hajime Hoshi 2021-01-11 23:54:43 +09:00
parent 3abb7a3604
commit c009070840
2 changed files with 15 additions and 0 deletions

View File

@ -99,6 +99,18 @@ func (p *Player) Play() {
p.cond.Signal()
}
func (p *Player) Reset() {
p.cond.L.Lock()
defer p.cond.L.Unlock()
if p.state == playerStateClosed {
return
}
p.v.Call("reset")
p.cond.Signal()
}
func (p *Player) Volume() float64 {
return p.v.Get("volume").Float()
}

View File

@ -30,6 +30,7 @@ type readerDriver interface {
type readerDriverPlayer interface {
Pause()
Play()
Reset()
Volume() float64
SetVolume(volume float64)
io.Closer
@ -121,6 +122,7 @@ func (p *readerPlayer) Current() time.Duration {
p.m.Lock()
defer p.m.Unlock()
// TODO: Add a new function to readerDriverPlayer and use it.
return p.src.Current()
}
@ -132,6 +134,7 @@ func (p *readerPlayer) Seek(offset time.Duration) error {
p.m.Lock()
defer p.m.Unlock()
p.player.Reset()
return p.src.Seek(offset)
}