mirror of
https://github.com/issadarkthing/gomu.git
synced 2025-04-28 13:48:53 +08:00
small refactor
This commit is contained in:
parent
82482342f1
commit
fcc9309886
@ -30,6 +30,7 @@ type Player struct {
|
|||||||
hasInit bool
|
hasInit bool
|
||||||
current string
|
current string
|
||||||
format *beep.Format
|
format *beep.Format
|
||||||
|
|
||||||
// to control the _volume internally
|
// to control the _volume internally
|
||||||
_volume *effects.Volume
|
_volume *effects.Volume
|
||||||
volume float64
|
volume float64
|
||||||
@ -104,6 +105,7 @@ func (p *Player) Run() {
|
|||||||
|
|
||||||
streamer, format, err := mp3.Decode(f)
|
streamer, format, err := mp3.Decode(f)
|
||||||
|
|
||||||
|
|
||||||
// song duration
|
// song duration
|
||||||
p.length = format.SampleRate.D(streamer.Len())
|
p.length = format.SampleRate.D(streamer.Len())
|
||||||
|
|
||||||
@ -188,12 +190,13 @@ func (p *Player) Run() {
|
|||||||
p.playingBar._progress = 0
|
p.playingBar._progress = 0
|
||||||
p.position = 0
|
p.position = 0
|
||||||
p.current = ""
|
p.current = ""
|
||||||
|
p.IsRunning = false
|
||||||
|
p.format = nil
|
||||||
|
|
||||||
if len(p.queue) != 0 {
|
if len(p.queue) != 0 {
|
||||||
go p.Run()
|
go p.Run()
|
||||||
} else {
|
|
||||||
p.IsRunning = false
|
|
||||||
p.format = nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
goto next
|
goto next
|
||||||
case <-time.After(time.Second):
|
case <-time.After(time.Second):
|
||||||
speaker.Lock()
|
speaker.Lock()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user