small refactor

This commit is contained in:
raziman 2020-06-23 19:28:12 +08:00
parent fa1bcb1f70
commit 0e85518099

View File

@ -137,7 +137,7 @@ func (p *Player) Run() {
p.done = done
sstreamer := beep.Seq(streamer, beep.Callback(func() {
// prevents from sending done channel is the song is skipped
// prevents from sending done channel if the song is skipped
if !p.isSkipped {
done <- true
} else {
@ -145,6 +145,7 @@ func (p *Player) Run() {
}
}))
ctrl := &beep.Ctrl{Streamer: sstreamer, Paused: false}
resampler := beep.ResampleRatio(4, 1, ctrl)
@ -203,10 +204,10 @@ next:
select {
case <-done:
close(done)
p.position = 0
p.current = ""
p.position = 0
p.current = ""
p.IsRunning = false
p.format = nil
p.format = nil
if len(p.queue) != 0 {
go p.Run()