Kodi Community Forum

Full Version: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Oh... yes, I meant the PVR, but I was not aware that it will not be in 'Eden'... what a pitty. Sad
I can't seem to figure out what arguments VideoPlayer.SeekTime() should have. According to the docs it should just require a integer argument, but that doesn't seem to work. I keep getting:

Code:
jsonrpclib.jsonrpc.ProtocolError: (-32602, 'Invalid params.')

Any ideas?
PWiddershoven Wrote:I can't seem to figure out what arguments VideoPlayer.SeekTime() should have. According to the docs it should just require a integer argument, but that doesn't seem to work. I keep getting:

Code:
jsonrpclib.jsonrpc.ProtocolError: (-32602, 'Invalid params.')

Any ideas?

It's just a wild guess on my part, but did you try something like mmConfuseds ?

e.g: 12:15

I realize that's not what is in the specs but maybe worth a try...
PWiddershoven Wrote:I can't seem to figure out what arguments VideoPlayer.SeekTime() should have. According to the docs it should just require a integer argument, but that doesn't seem to work. I keep getting:

Code:
jsonrpclib.jsonrpc.ProtocolError: (-32602, 'Invalid params.')

Any ideas?

SeekTime() should take a single integer. Can you please post the JSON request you send?
jitterjames Wrote:It's just a wild guess on my part, but did you try something like mmConfuseds ?

e.g: 12:15

I realize that's not what is in the specs but maybe worth a try...

Nope doesn't work either.

Montellese Wrote:SeekTime() should take a single integer. Can you please post the JSON request you send?

This is the request I'm sending (using jsonrpclib):

Code:
{"jsonrpc": "2.0", "params": [10], "id": "gfc5nrn0", "method": "videoplayer.seektime"}
Unfortunately XBMCs JSON RPC API is not yet fully compliant with the SJON RPC 2.0 specification. This means that all the methods which only take a single method do this by expecting the json value directly and not within an array or object. So currently the "valid" call would be
Code:
{"jsonrpc": "2.0", "params": 10, "id": "gfc5nrn0", "method": "videoplayer.seektime"}

But this is a known problem and I'm currently discussing with topfs2 how this would be solved best and I'm willing to fix this as soon as it is decided how (check Trac #10095 for more details).
Montellese Wrote:Unfortunately XBMCs JSON RPC API is not yet fully compliant with the SJON RPC 2.0 specification. This means that all the methods which only take a single method do this by expecting the json value directly and not within an array or object. So currently the "valid" call would be
Code:
{"jsonrpc": "2.0", "params": 10, "id": "gfc5nrn0", "method": "videoplayer.seektime"}

But this is a known problem and I'm currently discussing with topfs2 how this would be solved best and I'm willing to fix this as soon as it is decided how (check Trac #10095 for more details).

Hm I see. But unfortunately, passing the parameter like that doesn't work either:

Code:
'{\n   "error" : {\n      "code" : -32100,\n      "message" : "Failed to execute method."\n   },\n   "id" : "gfc5nrn0",\n   "jsonrpc" : "2.0"\n}\n'
PWiddershoven Wrote:Hm I see. But unfortunately, passing the parameter like that doesn't work either:

Code:
'{\n   "error" : {\n      "code" : -32100,\n      "message" : "Failed to execute method."\n   },\n   "id" : "gfc5nrn0",\n   "jsonrpc" : "2.0"\n}\n'

Actually it works but "Failed to execute method" in this context means that you called videoplayer.seektime() although the videoplayer is currently not playing any video.

All the *Player methods only do something if the actual player within XBMC is currently playing something.
Montellese Wrote:Actually it works but "Failed to execute method" in this context means that you called videoplayer.seektime() although the videoplayer is currently not playing any video.

All the *Player methods only do something if the actual player within XBMC is currently playing something.

Oh yes of course, sorry my bad Smile
topfs2 Wrote:....
EDIT: And when now I see remove and insert is commited to svn Smile http://trac.xbmc.org/changeset/34390 will check if its backportable

Is this Insert/Remove extension on schedule? Or how else I can remove item from the AudioPlaylist?
Command:
Code:
{"jsonrpc":"2.0", "method":"AudioPlaylist.Remove", "params":{"item":1}, "id":1}
returns:
Code:
{"error":{"code":-32601, "message":"Method not found."}, "id":1, "jsonrpc":"2.0"}
while somewhere in this thread suggested replacement:
Code:
{"jsonrpc":"2.0", "method":"Playlist.Remove", "params":{"playlist":"music", "item":1}, "id":1}
returns:
Code:
{"error":{"code":-32602, "message":"Invalid params."}, "id":1, "jsonrpc" : "2.0"}
Or the pure old xbmcHttp?command=RemoveFromPlaylist is the only way to do it?Smile
Hi topfs2, I was wondering if this has or will get implemented? I have tried a few combos and keep on getting all the songs in the library.

Quote:Originally Posted by jez500 View Post
1. Search : I found the combination of QueryMusicDatabase + LIKE %q% + searchbox + ajax resulted in powerful and fast itunes style searching. I can’t seem to make “MusicLibrary.GetSongs” do the same thing, is it possible? I am currently grabbing all songs at page load and looping through each item when searched - which I don’t think will scale well.

Great idea! I'll add some form of filter parameters to all the FooLibrary.GetBar calls.

Does
Code:

{"jsonrpc": "2.0", "method": "MusicLibrary.GetSongs", "params": { "filter": { "artist": "FOO", "album": "BAR" } } , "id": 1 }

Sounds like a plan?

It would be oh-so-handy being able to filter that GetSongs method (that can obviously get very large when you have a few songs - ~2.5Mb for 6000 songs).

One other thing, is it possible to give the AudioPlaylist.Add an array of song id's eg.

{"jsonrpc": "2.0", "method": "AudioPlaylist.Add", "params": { "songids": [34,56,167] } , "id": 1 }

This is proving to be a bit of a bottleneck in my application.

Thanks in advance and loving working with jsonrpc over the old httpapi!
Montellese Wrote:This is what I currently do using the System.CurrentControl and System.CurrentWindow InfoLabels. :

Hello Montellese,

my answer comes a little delayed, because I first needed to get some basic foundation programming done. (I decided to write my Client in Qt - and this is my first Qt project...) So thanks for your answer some weeks ago..

I can't find the functions you told me. I'm using the XBMC Darma Release from Dec, 17. JSONRPC.Introspect only shows me "System.GetInfoLabels" which returns an empty value.

So what am I missing?
Could someone point me t where I can find a list of what calls/procedures have been implemented under JSON?

Am I correct in my understanding that the simple "SendKeys" functionality of the HTTP api has not yet been implemented? Is there an alternative call in JSON with similar functionality?
jez500 Wrote:Hi topfs2 ... One other thing, is it possible to give the AudioPlaylist.Add an array of song id's eg.
{"jsonrpc": "2.0", "method": "AudioPlaylist.Add", "params": { "songids": [34,56,167] } , "id": 1 }
....
Another wishful thinking is adding the directory subtree, eg.
{"jsonrpc": "2.0", "method": "AudioPlaylist.Add", "params": { "directory": "myshares/jazz/flac/Christmas", "mode":"subtree","filter":"music"} , "id": 1 }
staeff Wrote:I can't find the functions you told me. I'm using the XBMC Darma Release from Dec, 17. JSONRPC.Introspect only shows me "System.GetInfoLabels" which returns an empty value.

So what am I missing?

You are missing to correct parameters to the System.GetInfoLabels method. You need to provide an array containing the labels you would like to retrieve
Code:
{ "jsonrpc": "2.0", "method": "System.GetInfoLabels", "params": ["System.CurrentControl", "System.CurrentWindow"], "id": 1 }
would be what you are after (it's not tested so maybe I made a mistake while typing it out of my head).

barrygordon Wrote:Could someone point me t where I can find a list of what calls/procedures have been implemented under JSON?
Calling the JSONRPC.Introspect method provides you with a list of all available methods. Otherwise you can check the source code here: JSONRPC.cpp. Simply scroll down a little and you will see a list of all methods and sometimes even a description.

barrygordon Wrote:Am I correct in my understanding that the simple "SendKeys" functionality of the HTTP api has not yet been implemented? Is there an alternative call in JSON with similar functionality?
You are right, there is no equivalent method in the JSON RPC api so far.