aboutsummaryrefslogtreecommitdiff
path: root/wrms.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-05-31 22:06:53 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2023-05-31 22:06:53 +0200
commit039881fdbfa69a33b27f84e8db3671fe8cfac5e6 (patch)
tree3746f6394f7999f1b6bf8826c9a364c11febc6ab /wrms.go
parent0d0b416146dd146a5dcfbf61f09f8136aa5afdc2 (diff)
downloadWRMS-039881fdbfa69a33b27f84e8db3671fe8cfac5e6.tar.gz
WRMS-039881fdbfa69a33b27f84e8db3671fe8cfac5e6.zip
support skipping the current song while playback is paused
Diffstat (limited to 'wrms.go')
-rw-r--r--wrms.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/wrms.go b/wrms.go
index fd1d10f..9409b49 100644
--- a/wrms.go
+++ b/wrms.go
@@ -151,7 +151,6 @@ func (wrms *Wrms) Broadcast(ev Event) {
func (wrms *Wrms) startPlaying() {
currentSong := wrms.CurrentSong.Load()
wrms.Broadcast(newEvent("play", []Song{*currentSong}))
- wrms.Player.Play(currentSong)
}
func (wrms *Wrms) AddSong(song Song) {
@@ -206,7 +205,11 @@ func (wrms *Wrms) Next() {
}
if wrms.Playing {
- wrms.startPlaying()
+ wrms.Broadcast(newEvent("play", []Song{*next}))
+ wrms.Player.Play(next)
+ } else if wrms.Player.mpv != nil {
+ wrms.Broadcast(newEvent("next", []Song{*next}))
+ wrms.Player.terminateMpv()
}
}
@@ -214,11 +217,17 @@ func (wrms *Wrms) PlayPause() {
wrms.Playing = !wrms.Playing
if wrms.Playing {
- if wrms.CurrentSong.Load() == nil {
+ currentSong := wrms.CurrentSong.Load()
+ if currentSong == nil {
llog.Info("No song currently playing play the next")
wrms.Next()
} else {
- wrms.startPlaying()
+ wrms.Broadcast(newEvent("play", []Song{*currentSong}))
+ if wrms.Player.mpv != nil {
+ wrms.Player.Continue()
+ } else {
+ wrms.Player.Play(currentSong)
+ }
}
} else {
wrms.Broadcast(newNotification("pause"))