aboutsummaryrefslogtreecommitdiff
path: root/player.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 /player.go
parent0d0b416146dd146a5dcfbf61f09f8136aa5afdc2 (diff)
downloadWRMS-039881fdbfa69a33b27f84e8db3671fe8cfac5e6.tar.gz
WRMS-039881fdbfa69a33b27f84e8db3671fe8cfac5e6.zip
support skipping the current song while playback is paused
Diffstat (limited to 'player.go')
-rw-r--r--player.go33
1 files changed, 23 insertions, 10 deletions
diff --git a/player.go b/player.go
index db4457c..2e1e7bf 100644
--- a/player.go
+++ b/player.go
@@ -48,15 +48,6 @@ func NewPlayer(wrms *Wrms, backends []string) Player {
}
func (player *Player) Play(song *Song) {
- if player.mpv != nil {
- llog.Debug("Send SIGCONT to mpv subprocess")
- err := player.mpv.Process.Signal(syscall.SIGCONT)
- if err != nil {
- llog.Fatal("Failed to send SIGCONT to mpv")
- }
- return
- }
-
llog.Info("Start playing %v", song)
player.Backends[song.Source].Play(song, player)
}
@@ -65,7 +56,7 @@ func (player *Player) runMpv() {
output, err := player.mpv.CombinedOutput()
if err != nil {
llog.Debug("Mpv output: %s", output)
- llog.Fatal("Mpv failed with: %s", err.Error())
+ llog.Fatal("Mpv failed with: %s", err)
}
currentSong := wrms.CurrentSong.Load()
@@ -77,6 +68,15 @@ func (player *Player) runMpv() {
wrms.Next()
}
+func (player *Player) terminateMpv() {
+ if player.mpv == nil {
+ llog.Fatal("Trying to terminate not running mpv process")
+ }
+
+ player.mpv.Process.Signal(syscall.SIGTERM)
+ player.mpv = nil
+}
+
const MPV_FLAGS = "--no-video"
func mpvArgv(uri string) []string {
@@ -133,6 +133,19 @@ func (player *Player) Pause() {
}
}
+func (player *Player) Continue() {
+ if player.mpv == nil {
+ llog.Warning("Continue Play but there is no running mpv process to continue")
+ return
+ }
+
+ llog.Debug("Send SIGCONT to mpv subprocess")
+ err := player.mpv.Process.Signal(syscall.SIGCONT)
+ if err != nil {
+ llog.Fatal("Failed to send SIGCONT to mpv")
+ }
+}
+
func (player *Player) Search(pattern string) chan []Song {
var wg sync.WaitGroup
wg.Add(len(player.Backends))