mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
audio: rename Seek -> SetPosition and Current -> Position
Seek and Current are not removed but marked as deprecated. Closes #2698
This commit is contained in:
parent
b2be456af8
commit
fbea792fe4
@ -368,13 +368,20 @@ func (p *Player) Rewind() error {
|
||||
return p.p.Rewind()
|
||||
}
|
||||
|
||||
// SetPosition sets the position with the given offset.
|
||||
//
|
||||
// The passed source to NewPlayer must be io.Seeker, or SetPosition panics.
|
||||
//
|
||||
// SetPosition returns error when seeking the source stream returns an error.
|
||||
func (p *Player) SetPosition(offset time.Duration) error {
|
||||
return p.p.SetPosition(offset)
|
||||
}
|
||||
|
||||
// Seek seeks the position with the given offset.
|
||||
//
|
||||
// The passed source to NewPlayer must be io.Seeker, or Seek panics.
|
||||
//
|
||||
// Seek returns error when seeking the source stream returns error.
|
||||
// Deprecated: as of v2.6. Use SetPosition instead.
|
||||
func (p *Player) Seek(offset time.Duration) error {
|
||||
return p.p.Seek(offset)
|
||||
return p.SetPosition(offset)
|
||||
}
|
||||
|
||||
// Pause pauses the playing.
|
||||
@ -382,12 +389,19 @@ func (p *Player) Pause() {
|
||||
p.p.Pause()
|
||||
}
|
||||
|
||||
// Position returns the current position in time.
|
||||
//
|
||||
// As long as the player continues to play, Position's returning value is increased monotonically,
|
||||
// even though the source stream loops and its position goes back.
|
||||
func (p *Player) Position() time.Duration {
|
||||
return p.p.Position()
|
||||
}
|
||||
|
||||
// Current returns the current position in time.
|
||||
//
|
||||
// As long as the player continues to play, Current's returning value is increased monotonically,
|
||||
// even though the source stream loops and its position goes back.
|
||||
// Deprecated: as of v2.6. Use Position instead.
|
||||
func (p *Player) Current() time.Duration {
|
||||
return p.p.Current()
|
||||
return p.Position()
|
||||
}
|
||||
|
||||
// Volume returns the current volume of this player [0-1].
|
||||
|
@ -243,7 +243,7 @@ func (p *playerImpl) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *playerImpl) Current() time.Duration {
|
||||
func (p *playerImpl) Position() time.Duration {
|
||||
p.m.Lock()
|
||||
defer p.m.Unlock()
|
||||
if err := p.ensurePlayer(); err != nil {
|
||||
@ -256,10 +256,10 @@ func (p *playerImpl) Current() time.Duration {
|
||||
}
|
||||
|
||||
func (p *playerImpl) Rewind() error {
|
||||
return p.Seek(0)
|
||||
return p.SetPosition(0)
|
||||
}
|
||||
|
||||
func (p *playerImpl) Seek(offset time.Duration) error {
|
||||
func (p *playerImpl) SetPosition(offset time.Duration) error {
|
||||
p.m.Lock()
|
||||
defer p.m.Unlock()
|
||||
|
||||
|
@ -199,7 +199,7 @@ func (p *Player) update() error {
|
||||
}
|
||||
|
||||
if p.audioPlayer.IsPlaying() {
|
||||
p.current = p.audioPlayer.Current()
|
||||
p.current = p.audioPlayer.Position()
|
||||
}
|
||||
if err := p.seekBarIfNeeded(); err != nil {
|
||||
return err
|
||||
@ -327,7 +327,7 @@ func (p *Player) seekBarIfNeeded() error {
|
||||
}
|
||||
pos := time.Duration(x-bx) * p.total / time.Duration(bw)
|
||||
p.current = pos
|
||||
if err := p.audioPlayer.Seek(pos); err != nil {
|
||||
if err := p.audioPlayer.SetPosition(pos); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
@ -73,9 +73,9 @@ func (g *Game) Update() error {
|
||||
}
|
||||
|
||||
func (g *Game) Draw(screen *ebiten.Image) {
|
||||
pos := g.player.Current()
|
||||
pos := g.player.Position()
|
||||
if pos > 5*time.Second {
|
||||
pos = (g.player.Current()-5*time.Second)%(4*time.Second) + 5*time.Second
|
||||
pos = (g.player.Position()-5*time.Second)%(4*time.Second) + 5*time.Second
|
||||
}
|
||||
msg := fmt.Sprintf(`TPS: %0.2f
|
||||
This is an example using
|
||||
|
@ -104,7 +104,7 @@ func (g *Game) Update() error {
|
||||
}
|
||||
|
||||
func (g *Game) Draw(screen *ebiten.Image) {
|
||||
pos := g.player.Current()
|
||||
pos := g.player.Position()
|
||||
msg := fmt.Sprintf(`TPS: %0.2f
|
||||
This is an example using
|
||||
stereo audio panning.
|
||||
|
Loading…
Reference in New Issue
Block a user