This commit is contained in:
raziman 2020-06-25 14:12:02 +08:00
parent c86a4965d5
commit ecf5ed628c

View File

@ -171,8 +171,7 @@ func (p *Player) Run() {
p.playingBar.NewProgress(song.name, int(p.length.Seconds()), 100)
p.playingBar.Run()
go func() {
// is used to send progress
i := 0
next:
@ -182,30 +181,6 @@ func (p *Player) Run() {
case <-p.isSkipped:
break next
case <-time.After(time.Second):
// stop progress bar from progressing when paused
if !p.IsRunning {
continue
}
i++
p.playingBar.progress <- 1
if i > p.playingBar.full {
break next
}
}
}
}()
next:
for {
select {
case <-done:
close(done)
p.position = 0
@ -218,15 +193,31 @@ next:
go p.Run()
}
break next
case <-time.After(time.Second):
// stop progress bar from progressing when paused
if !p.IsRunning {
continue
}
i++
p.playingBar.progress <- 1
speaker.Lock()
p.position = position()
speaker.Unlock()
if i > p.playingBar.full {
break next
}
}
}
}
func (p *Player) Pause() {
speaker.Lock()
p.ctrl.Paused = true