audio: Bug fix: Continue to play the audio after seeking on go2cpp

This commit is contained in:
Hajime Hoshi 2021-02-21 23:54:43 +09:00
parent 311d53ce2e
commit 29099cf660
2 changed files with 8 additions and 0 deletions

View File

@ -149,6 +149,8 @@ func (p *Player) Reset() {
if p.state == playerStateClosed {
return
}
p.state = playerStatePaused
if !p.v.Truthy() {
return
}

View File

@ -117,6 +117,7 @@ func (p *readerPlayer) Current() time.Duration {
defer p.m.Unlock()
// TODO: Add a new function to readerDriverPlayer and use it.
// src's position doesn't reflect the exact playing position.
return p.src.Current()
}
@ -128,6 +129,11 @@ func (p *readerPlayer) Seek(offset time.Duration) error {
p.m.Lock()
defer p.m.Unlock()
if p.player.IsPlaying() {
defer func() {
p.player.Play()
}()
}
p.player.Reset()
return p.src.Seek(offset)
}