diff options
author | Florrie <towerofnix@gmail.com> | 2020-07-12 17:56:33 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-05-16 19:04:54 -0300 |
commit | 1be05b974e5ff09fbab1cda89b2f4223cd97bedb (patch) | |
tree | c03f338a66bff0b4d0481d4c8a6fb5b4e7103a3f | |
parent | 1f916d3acd03acdc67699e24015562a3d2422f27 (diff) |
support stop-playing over client sockets
-rw-r--r-- | backend.js | 1 | ||||
-rw-r--r-- | socket.js | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/backend.js b/backend.js index 6e669d9..3b2343e 100644 --- a/backend.js +++ b/backend.js @@ -559,6 +559,7 @@ class QueuePlayer extends EventEmitter { this.playingTrack = null this.timeData = null this.time = null + this.emit('playing details', null, oldTrack, 0, this) this.emit('playing', null, oldTrack, 0, this) } } 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 + }) } }) |