mirror of
https://github.com/issadarkthing/gomu.git
synced 2025-04-28 13:48:53 +08:00
refactor
This commit is contained in:
parent
c86a4965d5
commit
ecf5ed628c
53
player.go
53
player.go
@ -171,41 +171,16 @@ func (p *Player) Run() {
|
||||
p.playingBar.NewProgress(song.name, int(p.length.Seconds()), 100)
|
||||
p.playingBar.Run()
|
||||
|
||||
go func() {
|
||||
|
||||
i := 0
|
||||
|
||||
next:
|
||||
for {
|
||||
|
||||
select {
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}()
|
||||
// is used to send progress
|
||||
i := 0
|
||||
|
||||
next:
|
||||
|
||||
for {
|
||||
|
||||
select {
|
||||
case <-p.isSkipped:
|
||||
break next
|
||||
|
||||
case <-done:
|
||||
close(done)
|
||||
p.position = 0
|
||||
@ -218,13 +193,29 @@ 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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user