aboutsummaryrefslogtreecommitdiff
path: root/wrms.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2022-07-26 21:37:24 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2022-07-26 21:37:24 +0200
commit7e15ad1d8af4ee27f6c1d31e7b1608e2d751c402 (patch)
tree157a86cd3597d51b3fe72e73bd4e782bda07b2d0 /wrms.go
parent8171af55daad6ce9a5cdacf95527801e83f25c08 (diff)
downloadWRMS-7e15ad1d8af4ee27f6c1d31e7b1608e2d751c402.tar.gz
WRMS-7e15ad1d8af4ee27f6c1d31e7b1608e2d751c402.zip
intermediate commit
* use mpv to play songs * fix CurrentSong being a pointer to a changing slot in the playlist array * wire up play and pause * continue playing after a song is finished
Diffstat (limited to 'wrms.go')
-rw-r--r--wrms.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/wrms.go b/wrms.go
index ee21c27..4df78fa 100644
--- a/wrms.go
+++ b/wrms.go
@@ -59,14 +59,14 @@ type Wrms struct {
Connections []Connection
Songs []Song
Queue Playlist
- CurrentSong *Song
+ CurrentSong Song
Player Player
Playing bool
}
func NewWrms() Wrms {
wrms := Wrms{}
- wrms.Player = NewPlayer()
+ wrms.Player = NewPlayer(&wrms)
return wrms
}
@@ -91,7 +91,7 @@ func (wrms *Wrms) AddSong(song Song) {
}
func (wrms *Wrms) Next() {
- wrms.CurrentSong = wrms.Queue.PopSong()
+ wrms.CurrentSong = *wrms.Queue.PopSong()
for i, s := range wrms.Songs {
if s.Uri == wrms.CurrentSong.Uri {
wrms.Songs[i] = wrms.Songs[len(wrms.Songs)-1]
@@ -104,13 +104,15 @@ func (wrms *Wrms) Next() {
func (wrms *Wrms) PlayPause() {
var ev Event
if !wrms.Playing {
- if wrms.CurrentSong == nil {
+ if wrms.CurrentSong.Uri == "" {
+ log.Println("No song currently playing play the next")
wrms.Next()
}
- ev = Event{"play", []Song{*wrms.CurrentSong}}
- wrms.Player.Play(wrms.CurrentSong)
+ ev = Event{"play", []Song{wrms.CurrentSong}}
+ wrms.Player.Play(&wrms.CurrentSong)
} else {
ev = Event{"pause", []Song{}}
+ wrms.Player.Pause()
}
wrms.Playing = !wrms.Playing