mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-14 15:07:26 +01:00
audio: Bug fix: Continue to play the audio after seeking on go2cpp
This commit is contained in:
parent
311d53ce2e
commit
29099cf660
@ -149,6 +149,8 @@ func (p *Player) Reset() {
|
|||||||
if p.state == playerStateClosed {
|
if p.state == playerStateClosed {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
p.state = playerStatePaused
|
||||||
|
|
||||||
if !p.v.Truthy() {
|
if !p.v.Truthy() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,7 @@ func (p *readerPlayer) Current() time.Duration {
|
|||||||
defer p.m.Unlock()
|
defer p.m.Unlock()
|
||||||
|
|
||||||
// TODO: Add a new function to readerDriverPlayer and use it.
|
// TODO: Add a new function to readerDriverPlayer and use it.
|
||||||
|
// src's position doesn't reflect the exact playing position.
|
||||||
return p.src.Current()
|
return p.src.Current()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,6 +129,11 @@ func (p *readerPlayer) Seek(offset time.Duration) error {
|
|||||||
p.m.Lock()
|
p.m.Lock()
|
||||||
defer p.m.Unlock()
|
defer p.m.Unlock()
|
||||||
|
|
||||||
|
if p.player.IsPlaying() {
|
||||||
|
defer func() {
|
||||||
|
p.player.Play()
|
||||||
|
}()
|
||||||
|
}
|
||||||
p.player.Reset()
|
p.player.Reset()
|
||||||
return p.src.Seek(offset)
|
return p.src.Seek(offset)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user