mirror of
https://github.com/mrusme/superhighway84.git
synced 2024-11-15 06:12:48 +00:00
48 lines
880 B
Go
48 lines
880 B
Go
//go:build poolsuite
|
|
|
|
package common
|
|
|
|
import(
|
|
"github.com/mrusme/go-poolsuite"
|
|
)
|
|
|
|
type Player struct {
|
|
Poolsuite *poolsuite.Poolsuite
|
|
poolsuiteLoaded bool
|
|
poolsuitePlaying bool
|
|
}
|
|
|
|
func NewPlayer() (*Player) {
|
|
player := new(Player)
|
|
|
|
player.Poolsuite = poolsuite.NewPoolsuite()
|
|
player.poolsuiteLoaded = false
|
|
player.poolsuitePlaying = false
|
|
|
|
return player
|
|
}
|
|
|
|
func (p *Player) poolsuitePlay() {
|
|
p.Poolsuite.Play(
|
|
p.Poolsuite.GetRandomTrackFromPlaylist(
|
|
p.Poolsuite.GetRandomPlaylist(),
|
|
),
|
|
func() { p.poolsuitePlay() },
|
|
)
|
|
}
|
|
|
|
func (p *Player) Play() {
|
|
if p.poolsuiteLoaded == false {
|
|
p.poolsuiteLoaded = true
|
|
p.Poolsuite.Load()
|
|
}
|
|
|
|
if p.poolsuitePlaying == false {
|
|
p.poolsuitePlay()
|
|
p.poolsuitePlaying = true
|
|
} else {
|
|
p.Poolsuite.PauseResume()
|
|
p.poolsuitePlaying = false
|
|
}
|
|
}
|