Update API docs

This commit is contained in:
badaix 2021-10-21 17:41:56 +02:00
parent 2983145b6c
commit e1eef690b4
3 changed files with 62 additions and 26 deletions

View file

@ -16,7 +16,7 @@ Used to control the player
{"id": 1, "jsonrpc": "2.0", "method": "Plugin.Stream.Player.Control", "params": {"command": "<command>", "params": { "<param 1>": <value 1>, "<param 2>": <value 2>}}} {"id": 1, "jsonrpc": "2.0", "method": "Plugin.Stream.Player.Control", "params": {"command": "<command>", "params": { "<param 1>": <value 1>, "<param 2>": <value 2>}}}
``` ```
Supported `command`s: #### Supported `command`s:
- `Play`: Start playback - `Play`: Start playback
- `params`: none - `params`: none
@ -36,7 +36,7 @@ Supported `command`s:
- `SetPosition`: Set the current track position in seconds - `SetPosition`: Set the current track position in seconds
- `params`: - `params`:
- `Position`: [float] the new track position - `Position`: [float] the new track position
- `TrackId`: [string] the optional currently playing track's identifier - `TrackId`: [string] the optional currently playing track's identifier
#### Example #### Example
@ -101,6 +101,8 @@ Success:
```json ```json
{"id": 1, "jsonrpc": "2.0", "result": {"canControl":true,"canGoNext":true,"canGoPrevious":true,"canPause":true,"canPlay":true,"canSeek":false,"loopStatus":"none","playbackStatus":"playing","position":593.394,"shuffle":false,"volume":86}} {"id": 1, "jsonrpc": "2.0", "result": {"canControl":true,"canGoNext":true,"canGoPrevious":true,"canPause":true,"canPlay":true,"canSeek":false,"loopStatus":"none","playbackStatus":"playing","position":593.394,"shuffle":false,"volume":86}}
{"id": 1, "jsonrpc": "2.0", "result": {"canControl":true,"canGoNext":true,"canGoPrevious":true,"canPause":true,"canPlay":true,"canSeek":true,"loopStatus":"none","metadata":{"album":"Doldinger","albumArtist":["Klaus Doldinger's Passport"],"artUrl":"http://coverartarchive.org/release/0d4ff56b-2a2b-43b5-bf99-063cac1599e5/16940576164-250.jpg","artist":["Klaus Doldinger's Passport feat. Nils Landgren"],"contentCreated":"2016","duration":305.2929992675781,"genre":["Jazz"],"musicbrainzAlbumId":"0d4ff56b-2a2b-43b5-bf99-063cac1599e5","title":"Soul Town","trackId":"7","trackNumber":6,"url":"Klaus Doldinger's Passport - Doldinger (2016)/06 - Soul Town.mp3"},"playbackStatus":"playing","position":72.79499816894531,"shuffle":false,"volume":97}}
``` ```
#### Supported `property`s #### Supported `property`s
@ -130,22 +132,6 @@ Error:
todo todo
``` ```
### Plugin.Stream.Player.GetMetadata
TODO: Metadata are part of the properties
```json
{"id": 1, "jsonrpc": "2.0", "method": "Plugin.Stream.Player.GetMetadata"}
```
#### Expected response
Success:
```json
{"id": 1, "jsonrpc": "2.0", "result": {"artist":["Travis Scott & HVME"],"file":"http://wdr-1live-live.icecast.wdr.de/wdr/1live/live/mp3/128/stream.mp3","name":"1Live, Westdeutscher Rundfunk Koeln","title":"Goosebumps (Remix)","trackId":"3"}}
```
## Notifications ## Notifications
### Plugin.Stream.Player.Metadata ### Plugin.Stream.Player.Metadata

View file

@ -157,7 +157,8 @@ The Server JSON object contains a list of Groups and Streams. Every Group holds
* Stream * Stream
* [Stream.AddStream](#streamaddstream) * [Stream.AddStream](#streamaddstream)
* [Stream.RemoveStream](#streamremovestream) * [Stream.RemoveStream](#streamremovestream)
* [Stream.SetMeta](#streamaddmeta) * [Stream.Control](#streamcontrol)
* [Stream.SetProperty](#streamsetproperty)
### Notifications ### Notifications
* Client * Client
@ -171,7 +172,7 @@ The Server JSON object contains a list of Groups and Streams. Every Group holds
* [Group.OnStreamChanged](#grouponstreamchanged) * [Group.OnStreamChanged](#grouponstreamchanged)
* [Group.OnNameChanged](#grouponnamechanged) * [Group.OnNameChanged](#grouponnamechanged)
* Stream * Stream
* [Stream.OnMetadata](#streamonmetadata) * [Stream.OnProperties](#streamonproperties)
* [Stream.OnUpdate](#streamonupdate) * [Stream.OnUpdate](#streamonupdate)
* Server * Server
* [Server.OnUpdate](#serveronupdate) * [Server.OnUpdate](#serveronupdate)
@ -380,15 +381,62 @@ The Server JSON object contains a list of Groups and Streams. Every Group holds
``` ```
### Stream.SetMeta ### Stream.Control
#### Request #### Request
```json ```json
{"id":4,"jsonrpc":"2.0","method":"Stream.SetMeta","params":{"id":"Spotify", "metadata": {"album": "some album", "artist": "some artist", "track": "some track"...}}} {"id": 1, "jsonrpc": "2.0", "method": "Stream.Control", "params": {"command": "<command>", "params": { "<param 1>": <value 1>, "<param 2>": <value 2>}}}
{"id":4,"jsonrpc":"2.0","method":"Stream.Control","params":{"id":"Spotify", "command": "next", params: {}}}
{"id":4,"jsonrpc":"2.0","method":"Stream.Control","params":{"id":"Spotify", "command": "seek", "param": "60"}}
``` ```
#### Supported `command`s:
- `Play`: Start playback
- `params`: none
- `Pause`: Stop playback
- `params`: none
- `PlayPause`: Toggle play/pause
- `params`: none
- `Stop`: Stop playback
- `params`: none
- `Next`: Skip to next track
- `params`: none
- `Previous`: Skip to previous track
- `params`: none
- `Seek`: Seek forward or backward in the current track
- `params`:
- `Offset`: [float] seek offset in seconds
- `SetPosition`: Set the current track position in seconds
- `params`:
- `Position`: [float] the new track position
- `TrackId`: [string] the optional currently playing track's identifier
#### Response #### Response
```json ```json
{"id":4,"jsonrpc":"2.0","result":{"id":"Spotify"}} TODO
```
### Stream.SetProperty
#### Request
```json
{"id": 1, "jsonrpc": "2.0", "method": "Stream.SetProperty", "params": {"id": "Pipe", "property": property, "value": value}}
{"id":4,"jsonrpc":"2.0","method":"Stream.Control","params":{"id":"Spotify", "command": "next", params: {}}}
{"id":4,"jsonrpc":"2.0","method":"Stream.Control","params":{"id":"Spotify", "command": "seek", "param": "60000"}}
```
#### Supported `property`s
- `loopStatus`: [string] the current repeat status, one of:
- `none`: the playback will stop when there are no more tracks to play
- `track`: the current track will start again from the begining once it has finished playing
- `playlist`: the playback loops through a list of tracks
- `shuffle`: [bool] play playlist in random order
- `volume`: [int] voume in percent, valid range [0..100]
- `rate`: [float] The current playback rate, valid range (0..)
#### Response
```json
TODO
``` ```
## Notifications ## Notifications
@ -437,9 +485,11 @@ The Server JSON object contains a list of Groups and Streams. Every Group holds
{"jsonrpc":"2.0","method":"Stream.OnUpdate","params":{"id":"stream 1","stream":{"id":"stream 1","status":"idle","uri":{"fragment":"","host":"","path":"/tmp/snapfifo","query":{"chunk_ms":"20","codec":"flac","name":"stream 1","sampleformat":"48000:16:2"},"raw":"pipe:///tmp/snapfifo?name=stream 1","scheme":"pipe"}}}} {"jsonrpc":"2.0","method":"Stream.OnUpdate","params":{"id":"stream 1","stream":{"id":"stream 1","status":"idle","uri":{"fragment":"","host":"","path":"/tmp/snapfifo","query":{"chunk_ms":"20","codec":"flac","name":"stream 1","sampleformat":"48000:16:2"},"raw":"pipe:///tmp/snapfifo?name=stream 1","scheme":"pipe"}}}}
``` ```
### Stream.OnMetadata ### Stream.OnProperties
```json ```json
{"jsonrpc":"2.0","method":"Stream.OnMetadata","params":{"id":"stream 1", "metadata": {"album": "some album", "artist": "some artist", "track": "some track"...}}} {"jsonrpc":"2.0","method":"Stream.OnProperties","params":{"id":"stream 1", "metadata": {"album": "some album", "artist": "some artist", "track": "some track"...}}}
{"jsonrpc":"2.0","method":"Stream.OnProperties","params":{"id":"Meta","properties":{"canControl":true,"canGoNext":true,"canGoPrevious":true,"canPause":true,"canPlay":true,"canSeek":true,"loopStatus":"none","metadata":{"album":"Doldinger","albumArtist":["Klaus Doldinger's Passport"],"artUrl":"http://coverartarchive.org/release/0d4ff56b-2a2b-43b5-bf99-063cac1599e5/16940576164-250.jpg","artist":["Klaus Doldinger's Passport feat. Nils Landgren"],"contentCreated":"2016","duration":305.2929992675781,"genre":["Jazz"],"title":"Soul Town","trackId":"7","trackNumber":6,"url":"Klaus Doldinger's Passport - Doldinger (2016)/06 - Soul Town.mp3"},"playbackStatus":"playing","position":221.82400512695313,"shuffle":false,"volume":97}}}
``` ```
### Server.OnUpdate ### Server.OnUpdate

View file

@ -53,7 +53,7 @@ void Server::onPropertiesChanged(const PcmStream* pcmStream, const Properties& p
{ {
LOG(DEBUG, LOG_TAG) << "Properties changed, stream: " << pcmStream->getName() << ", properties: " << properties.toJson().dump(3) << "\n"; LOG(DEBUG, LOG_TAG) << "Properties changed, stream: " << pcmStream->getName() << ", properties: " << properties.toJson().dump(3) << "\n";
// Send propeties to all connected control clients // Send properties to all connected control clients
json notification = json notification =
jsonrpcpp::Notification("Stream.OnProperties", jsonrpcpp::Parameter("id", pcmStream->getId(), "properties", properties.toJson())).to_json(); jsonrpcpp::Notification("Stream.OnProperties", jsonrpcpp::Parameter("id", pcmStream->getId(), "properties", properties.toJson())).to_json();
controlServer_->send(notification.dump(), nullptr); controlServer_->send(notification.dump(), nullptr);