Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding addtoqueue API call #766

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 addtoqueue response:
```
[
{"firsttracknumberenqueued":"4","numtracksadded":"1","newqueuelength":"4"}
]

```

Preset
------
Expand Down
13 changes: 13 additions & 0 deletions lib/actions/addToQueue.js
Original file line number Diff line number Diff line change
@@ -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);
};