From 78ef0a8c344224cf0c49f4d5f4da930d90534424 Mon Sep 17 00:00:00 2001 From: Barry de Graaff Date: Sun, 12 Jul 2020 09:35:27 +0200 Subject: [PATCH 1/2] adding addtoqueue API call --- README.md | 20 ++++++++++++++++++++ lib/actions/addToQueue.js | 13 +++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 lib/actions/addToQueue.js diff --git a/README.md b/README.md index 997f6a59..f6c609b1 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,7 @@ The actions supported as of today: * saypreset * queue * clearqueue +* addtoqueue * sleep (values in seconds) * linein (only analog linein, not PLAYBAR yet) * clip (announce custom mp3 clip) @@ -184,6 +185,25 @@ Example queue response: ``` +addtoqueue (beta) +----- +Add track to the current queue of specified player. You can obtain track uri from /favorites/detailed call. When using Sonos music library (CIFS) and know the path of a song you can construct the uri by using encodeURIComponent. The request will accept: + - uri (required, + - enqueueAsNext (boolean, required) + - desiredFirstTrackNumberEnqueued (optional) + + http://localhost:5005/living room/addtoqueue/x-file-cifs%3A%2F%2F10.10.1.77%2Fpublic%2FJames%20Bond%20Soundtracks%2F02.%20From%20Russia%20With%20Love%2F07%20-%20007.mp3/true/1 + http://localhost:5005/living room/addtoqueue/x-sonos-spotify:spotify%3atrack%3a4BggEwLhGfrbrl7JBhC8EC?sid=9&flags=8224&sn=2/true/1 + +addtoqueue works with Sonos music library (CIFS) and works partially with Spotify. Added songs from Spotify will display correct album art, but display song id instead of song title. + +Example queue response: +``` +[ + {"firsttracknumberenqueued":"4","numtracksadded":"1","newqueuelength":"4"} +] + +``` Preset ------ diff --git a/lib/actions/addToQueue.js b/lib/actions/addToQueue.js new file mode 100644 index 00000000..f51bedce --- /dev/null +++ b/lib/actions/addToQueue.js @@ -0,0 +1,13 @@ +'use strict'; + +function addtoqueue(player, values) { + const uri = decodeURIComponent(values[0]); + const enqueueAsNext = values[1]; + const desiredFirstTrackNumberEnqueued = values[2]; + const metadata = ""; + return player.coordinator.addURIToQueue(uri, metadata, enqueueAsNext, desiredFirstTrackNumberEnqueued); +} + +module.exports = function (api) { + api.registerAction('addtoqueue', addtoqueue); +}; From b0793b79de8cfdc9bed9e71c5ca436062ba37c4b Mon Sep 17 00:00:00 2001 From: Barry de Graaff Date: Sun, 12 Jul 2020 09:36:56 +0200 Subject: [PATCH 2/2] fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f6c609b1..fcf51897 100644 --- a/README.md +++ b/README.md @@ -197,7 +197,7 @@ Add track to the current queue of specified player. You can obtain track uri fro addtoqueue works with Sonos music library (CIFS) and works partially with Spotify. Added songs from Spotify will display correct album art, but display song id instead of song title. -Example queue response: +Example addtoqueue response: ``` [ {"firsttracknumberenqueued":"4","numtracksadded":"1","newqueuelength":"4"}