examples/audio: Improve the seeking message

This commit is contained in:
Hajime Hoshi 2017-06-04 17:12:31 +09:00
parent 8957b1b857
commit 7f39dc1e8b

View File

@ -93,6 +93,7 @@ type Player struct {
seBytes []uint8 seBytes []uint8
seCh chan []uint8 seCh chan []uint8
volume128 int volume128 int
previousPos time.Duration
} }
var ( var (
@ -249,6 +250,8 @@ func (p *Player) draw(screen *ebiten.Image) {
screen.DrawImage(playerBarImage, op) screen.DrawImage(playerBarImage, op)
currentTimeStr := "00:00" currentTimeStr := "00:00"
c := p.audioPlayer.Current() c := p.audioPlayer.Current()
prev := p.previousPos
p.previousPos = c
// Current Time // Current Time
m := (c / time.Minute) % 100 m := (c / time.Minute) % 100
@ -268,8 +271,8 @@ Press S to toggle Play/Pause
Press P to play SE Press P to play SE
Press Z or X to change volume of the music Press Z or X to change volume of the music
%s`, ebiten.CurrentFPS(), currentTimeStr) %s`, ebiten.CurrentFPS(), currentTimeStr)
if p.seekedCh != nil { if p.audioPlayer.IsPlaying() && prev == c {
msg += "\nSeeking..." msg += "\nLoading..."
} }
ebitenutil.DebugPrint(screen, msg) ebitenutil.DebugPrint(screen, msg)
} }