Kodi Community Forum
JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+---- Forum: JSON-RPC (https://forum.kodi.tv/forumdisplay.php?fid=174)
+---- Thread: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC (/showthread.php?tid=68263)



- Montellese - 2011-09-23

grywnn Wrote:I can open tickets for these two things if needed.

Please do that. Thanks.


- mzanetti - 2011-09-23

Montellese Wrote:Well it doesn't work in the sense that it will add all items from album 1 AND from artist 1. It will only add items from album 1 because the second "item" overwrites the first one.


The "item" parameter of Playlist.Add does only allow to contain a single propertie i.e. EITHER "artistid" OR "albumid" OR "songid" OR "movieid" OR ...

I might write a more detailed description about the "union type" feature of JSON schema which we use in our JSONRPC.Introspect. In short if you see something like this in introspect:
PHP Code:
"type": [
  { 
"type""object""properties": { "artistid": { "$ref""Library.Id""required"true } } },
  { 
"type""object""properties": { "albumid": { "$ref""Library.Id""required"true } } },
  ...

it means that you can either provide an object which contains a property "artistid" OR you can provide an object which contains a property "albumid" OR ... BUT you MUST NOT provide an object which contains more than one of those properties. The fact that the "type" is defined as an array of possible JSON schemas means that those JSON schemas exclude each other and only one of them can be valid for a specific JSON object.

Ok... got it... Actually this all makes sense... It's just that I had everything in place with the old API and I got used to how it was working there... The new API behaves quite different then and confused me. Anyways, thanks for the clarifications.


- Montellese - 2011-09-23

Yeah the new API is quite a dramatic change but we thought that now is the only chance we'll ever get to make such a change because we already dropped backwards compatibility to Dharma with all the other changes in jsonrpc. So we took the chance to create a clean API on which we can build in the future.

I know that JSON schema is not always easy to understand (apart from the obvious properties like "minimum" and "maximum"). It took me a while as well to get my head around the "union type definitions" as it is not very well described in the JSON schema specification and I had to study quite a few examples until I grasped the meaning and usage of it. So feel free to ask if you are not sure instead of trying for hours and not getting it to work.


- jasonvp - 2011-09-24

Hi guys,

Player.GetProperties/Player.Property.Name which replaced Player.State has no "playing" or "paused" option. Are these going to be added?


Cheers
Jason


- Montellese - 2011-09-24

jasonvp Wrote:Hi guys,

Player.GetProperties/Player.Property.Name which replaced Player.State has no "playing" or "paused" option. Are these going to be added?

We thought that having "playing" and "paused" was kindof overkill and then we decided that we use the "speed" property to determine whether a player is currently playing (speed != 0) or is paused (speed = 0).


- jasonvp - 2011-09-24

Montellese Wrote:We thought that having "playing" and "paused" was kindof overkill and then we decided that we use the "speed" property to determine whether a player is currently playing (speed != 0) or is paused (speed = 0).

Fair enough. I didn't pick up on that.

Cheers
Jason


- mzanetti - 2011-09-24

Calling this crashes xbmc:

Code:
"{ "id" : 22, "jsonrpc" : "2.0", "method" : "Playlist.Clear", "params" : { "playlistid" : 2 } }"
"{ "id" : 23, "jsonrpc" : "2.0", "method" : "Playlist.Add", "params" : { "item" : { "file" : "/home/user/Pictures/picture.jpg" }, "playlistid" : 2 } }"
"{ "id" : 24, "jsonrpc" : "2.0", "method" : "Player.Open", "params" : { "item" : { "playlistid" : 2, "position" : 0 } } }"
"{ "id" : 25, "jsonrpc" : "2.0", "method" : "Playlist.Clear", "params" : { "playlistid" : 2 } }"

This can be worked around by calling Player.Stop before the Playlist.Clear but still shouldn't happen I guess.


- jasonvp - 2011-09-25

Hi guys,

What am I doing wrong?

Code:
{"jsonrpc":"2.0","id":1,"method":"Player.SetSpeed","params":{"playerid":0,"speed":2}}

Code:
{"error":{"code":-32602,"data":{"method":"Player.SetSpeed","stack":{"message":"Received value does not match any of the union type definitions","name":"speed","type":["string","integer"]}},"message":"Invalid params."},"id":1,"jsonrpc":"2.0"}


Cheers
Jason


- Montellese - 2011-09-25

mzanetti Wrote:Calling this crashes xbmc:

Code:
"{ "id" : 22, "jsonrpc" : "2.0", "method" : "Playlist.Clear", "params" : { "playlistid" : 2 } }"
"{ "id" : 23, "jsonrpc" : "2.0", "method" : "Playlist.Add", "params" : { "item" : { "file" : "/home/user/Pictures/picture.jpg" }, "playlistid" : 2 } }"
"{ "id" : 24, "jsonrpc" : "2.0", "method" : "Player.Open", "params" : { "item" : { "playlistid" : 2, "position" : 0 } } }"
"{ "id" : 25, "jsonrpc" : "2.0", "method" : "Playlist.Clear", "params" : { "playlistid" : 2 } }"

This can be worked around by calling Player.Stop before the Playlist.Clear but still shouldn't happen I guess.
Thanks for the report. I thought I had tried all those cases but seems like I didn't do it right. Could you please create a bug report on Trac so I don't forget?

jasonvp Wrote:Hi guys,

What am I doing wrong?

Code:
{"jsonrpc":"2.0","id":1,"method":"Player.SetSpeed","params":{"playerid":0,"speed":2}}

Code:
{"error":{"code":-32602,"data":{"method":"Player.SetSpeed","stack":{"message":"Received value does not match any of the union type definitions","name":"speed","type":["string","integer"]}},"message":"Invalid params."},"id":1,"jsonrpc":"2.0"}

Broken here as well. Probably a bug in my union type implementation. Please create a bug ticket as well. Thanks.


- jasonvp - 2011-09-25

Montellese Wrote:Broken here as well. Probably a bug in my union type implementation. Please create a bug ticket as well. Thanks.

Thanks Montellese.

Just to add, "increment" and "decrement" work but I'm just wondering what the speed values i.e. 2, 4, 8, 16 are suppose to represent?

e.g. I would have thought that "speed":2 would mean twice as fast as "speed":1 i.e. a song that is 4 minutes long would take 2 minutes to fast forward to the end. It currently only takes 4 seconds at "speed":2 using "increment" sent once. Seems to fast to me.


Cheers
Jason


- Montellese - 2011-09-25

jasonvp Wrote:Just to add, "increment" and "decrement" work but I'm just wondering what the speed values i.e. 2, 4, 8, 16 are suppose to represent?

e.g. I would have thought that "speed":2 would mean twice as fast as "speed":1 i.e. a song that is 4 minutes long would take 2 minutes to fast forward to the end. It currently only takes 4 seconds at "speed":2 using "increment" sent once. Seems to fast to me.

Yeah it was a bug in my union type implementation. I fixed it and Player.SetSpeed should now also work with the numerical values (btw I also added -32 and 32).

You are right, setting the playback speed to 2 on a playing song plays it way faster than 2 times the original speed. But when I use the Fast Forward functionality from the music player OSD in XBMC itself that's the way it works there as well. So jsonrpc simply works the way it works when using the GUI functionality. But I agree that it's not very intuitive.


- sling100 - 2011-09-25

Forgive me for the stupid question, but can someone explain to me how I load a .m3u list via JSON? I assume I use a Playlist.GetItems, I'm just not sure of the syntax for using a filename rather than a numerical ID.

Thanks

Simon


- jasonvp - 2011-09-26

Quote:Montellese;896673]Yeah it was a bug in my union type implementation. I fixed it and Player.SetSpeed should now also work with the numerical values (btw I also added -32 and 32).

Thank you.


Quote:You are right, setting the playback speed to 2 on a playing song plays it way faster than 2 times the original speed. But when I use the Fast Forward functionality from the music player OSD in XBMC itself that's the way it works there as well. So jsonrpc simply works the way it works when using the GUI functionality. But I agree that it's not very intuitive.

I did some more investigating and found that in the Video Player Fast Forward x2, x4 etc. work as you expect but Rewind speed is faster than expected. The Music Player is way out for both Fast Forward and Rewind...weird. I'll submit a Bug Ticket.

I also noticed that "fields" for "Playlist.GetItems" is not working with Windows GIT:20110924-0074b5e. It was working fine with GIT:20110919-8af9b11.
Result
Code:
{"code":-32602,"data":{"message":"Too many parameters","method":"Playlist.GetItems","stack":{"name":"playlistid","type":"integer"}},"message":"Invalid params."},"id":1,"jsonrpc":"2.0"}


Cheers
Jason


- Montellese - 2011-09-26

jasonvp Wrote:I did some more investigating and found that in the Video Player Fast Forward x2, x4 etc. work as you expect but Rewind speed is faster than expected. The Music Player is way out for both Fast Forward and Rewind...weird. I'll submit a Bug Ticket.

Yeah certainly someone (who implemented that functionality in the different players) knows about this better than I do.

jasonvp Wrote:I also noticed that "fields" for "Playlist.GetItems" is not working with Windows GIT:20110924-0074b5e. It was working fine with GIT:20110919-8af9b11.
Result
Code:
{"code":-32602,"data":{"message":"Too many parameters","method":"Playlist.GetItems","stack":{"name":"playlistid","type":"integer"}},"message":"Invalid params."},"id":1,"jsonrpc":"2.0"}

Probably because all "fields" parameters have been renamed to "properties" on 20th September (http://forum.xbmc.org/showpost.php?p=893214&postcount=1225) Wink


- jasonvp - 2011-09-26

Montellese Wrote:Probably because all "fields" parameters have been renamed to "properties" on 20th September (http://forum.xbmc.org/showpost.php?p=893214&postcount=1225) Wink

Sorry about that, missed that one.


Cheers
Jason