mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 11:48:55 +01:00
audio/internal/go2cpp: Add readerDriverPlayer.Reset
This commit is contained in:
parent
3abb7a3604
commit
c009070840
@ -99,6 +99,18 @@ func (p *Player) Play() {
|
|||||||
p.cond.Signal()
|
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 {
|
func (p *Player) Volume() float64 {
|
||||||
return p.v.Get("volume").Float()
|
return p.v.Get("volume").Float()
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ type readerDriver interface {
|
|||||||
type readerDriverPlayer interface {
|
type readerDriverPlayer interface {
|
||||||
Pause()
|
Pause()
|
||||||
Play()
|
Play()
|
||||||
|
Reset()
|
||||||
Volume() float64
|
Volume() float64
|
||||||
SetVolume(volume float64)
|
SetVolume(volume float64)
|
||||||
io.Closer
|
io.Closer
|
||||||
@ -121,6 +122,7 @@ func (p *readerPlayer) Current() time.Duration {
|
|||||||
p.m.Lock()
|
p.m.Lock()
|
||||||
defer p.m.Unlock()
|
defer p.m.Unlock()
|
||||||
|
|
||||||
|
// TODO: Add a new function to readerDriverPlayer and use it.
|
||||||
return p.src.Current()
|
return p.src.Current()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,6 +134,7 @@ func (p *readerPlayer) Seek(offset time.Duration) error {
|
|||||||
p.m.Lock()
|
p.m.Lock()
|
||||||
defer p.m.Unlock()
|
defer p.m.Unlock()
|
||||||
|
|
||||||
|
p.player.Reset()
|
||||||
return p.src.Seek(offset)
|
return p.src.Seek(offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user