« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/socket.js
diff options
context:
space:
mode:
Diffstat (limited to 'socket.js')
-rw-r--r--socket.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/socket.js b/socket.js
index e56f999..aae1504 100644
--- a/socket.js
+++ b/socket.js
@@ -162,6 +162,8 @@ function validateCommand(command) {
             ) ||
             command.status === 'sync-playback'
           )
+        case 'stop-playing':
+          return typeof command.queuePlayer === 'string'
         case 'unqueue':
           return (
             typeof command.queuePlayer === 'string' &&
@@ -450,6 +452,9 @@ export function attachBackendToSocketClient(backend, client, {
             }, command.startingTrack ? 500 : 0)
             return
           }
+          case 'stop-playing':
+            if (QP) silenceEvents(QP, ['playing'], () => QP.stopPlaying())
+            return
           case 'unqueue':
             if (QP) silenceEvents(QP, ['unqueue'], () => QP.unqueue(
               restoreNewItem(command.topItem, getPlaylistSources())
@@ -506,6 +511,11 @@ export function attachBackendToSocketClient(backend, client, {
           queuePlayer: queuePlayer.id
         })
       })
+    } else {
+      client.sendCommand({
+        code: 'stop-playing',
+        queuePlayer: queuePlayer.id
+      })
     }
   })