Skip to content

Commit

Permalink
Added shuffle parameter to /player/load endpoint (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
devgianlu committed Apr 3, 2021
1 parent 7747677 commit 100d248
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ All the endpoints will respond with `200` if successful or:
- `503` If the session is reconnecting (`Retry-After` is always 10 seconds)

### Player
- `POST /player/load` Load a track from a given URI. The request body should contain two parameters: `uri` and `play`.
- `POST /player/load` Load a track from a given URI `uri`, can specify to start playing with `play` and to shuffle with `shuffle`.
- `POST /player/play-pause` Toggle play/pause status. Useful when using a remote.
- `POST /player/pause` Pause playback.
- `POST /player/resume` Resume playback.
Expand Down Expand Up @@ -69,7 +69,7 @@ Use any endpoint from the [public Web API](https://developer.spotify.com/documen
The method, body, and content type headers will pass through. Additionally, you can specify an `X-Spotify-Scope` header to override the requested scope, by default all will be requested.

## Examples
`curl -X POST -d "uri=spotify:track:xxxxxxxxxxxxxxxxxxxxxx&play=true" http://localhost:24879/player/load`
`curl -X POST -d "uri=spotify:track:xxxxxxxxxxxxxxxxxxxxxx&play=true&shuffle=true" http://localhost:24879/player/load`

`curl -X POST http://localhost:24879/metadata/track/spotify:track:xxxxxxxxxxxxxxxxxxxxxx`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,13 @@ private static void setRepeat(HttpServerExchange exchange, @NotNull Player playe
}
}

private static void load(HttpServerExchange exchange, @NotNull Player player, @Nullable String uri, boolean play) {
private static void load(HttpServerExchange exchange, @NotNull Player player, @Nullable String uri, boolean play, boolean shuffle) {
if (uri == null) {
Utils.invalidParameter(exchange, "uri");
return;
}

player.setShuffle(shuffle);
player.load(uri, play);
}

Expand Down Expand Up @@ -210,7 +211,7 @@ protected void handleRequest(@NotNull HttpServerExchange exchange, @NotNull Sess
player.volumeDown();
return;
case LOAD:
load(exchange, player, Utils.getFirstString(params, "uri"), Utils.getFirstBoolean(params, "play"));
load(exchange, player, Utils.getFirstString(params, "uri"), Utils.getFirstBoolean(params, "play"), Utils.getFirstBoolean(params, "shuffle"));
return;
case PLAY_PAUSE:
player.playPause();
Expand Down

0 comments on commit 100d248

Please sign in to comment.