mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
parent
8e6907c64a
commit
7744013b05
@ -399,6 +399,11 @@ func (p *Player) SetVolume(volume float64) {
|
||||
p.p.SetVolume(volume)
|
||||
}
|
||||
|
||||
// UnplayedBufferSize returns the amount of unplayed data in the player's buffer in the time duration.
|
||||
func (p *Player) UnplayedBufferSize() time.Duration {
|
||||
return p.p.UnplayedBufferSize()
|
||||
}
|
||||
|
||||
type hook interface {
|
||||
OnSuspendAudio(f func() error)
|
||||
OnResumeAudio(f func() error)
|
||||
|
@ -245,8 +245,8 @@ func (p *playerImpl) Current() time.Duration {
|
||||
return 0
|
||||
}
|
||||
|
||||
sample := (p.stream.Current() - int64(p.player.UnplayedBufferSize())) / bytesPerSample
|
||||
return time.Duration(sample) * time.Second / time.Duration(p.factory.sampleRate)
|
||||
samples := (p.stream.Current() - int64(p.player.UnplayedBufferSize())) / bytesPerSample
|
||||
return time.Duration(samples) * time.Second / time.Duration(p.factory.sampleRate)
|
||||
}
|
||||
|
||||
func (p *playerImpl) Rewind() error {
|
||||
@ -280,6 +280,18 @@ func (p *playerImpl) Err() error {
|
||||
return p.player.Err()
|
||||
}
|
||||
|
||||
func (p *playerImpl) UnplayedBufferSize() time.Duration {
|
||||
p.m.Lock()
|
||||
defer p.m.Unlock()
|
||||
|
||||
if p.player == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
samples := p.player.UnplayedBufferSize() / bytesPerSample
|
||||
return time.Duration(samples) * time.Second / time.Duration(p.factory.sampleRate)
|
||||
}
|
||||
|
||||
func (p *playerImpl) source() io.Reader {
|
||||
return p.src
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user