• 1
  • 114
  • 115
  • 116(current)
  • 117
  • 118
  • 226
JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC
Ticket added : http://trac.xbmc.org/ticket/12663

As long as the id does not change, we can batch the pause for id 1 and 2, but this is just another way to abuse the system Smile

Instead of id -1 I've think about just adding a new command like PlayPauseAll so we don't allow -1 only on some commands and people get lost. Just a special command for special cases.
Reply
Am I miss understanding limits or is it +1 on the total and end?
On movies for example:
Code:
{ end=597, start=0, total=597 }
Yet the last in the movies array is 596. Same thing with TV, artists and albums. I've not checked the rest.
Image
AWXi - Ajax web interface. Wiki
Reply
It's probably more that the name "end" is a bit confusing and the fact that indices always start at 0 in computing so the last element is size -1 (or total - 1). It means something like "size" but not with the same meaning as the "total" property. "total" tells you how many items there are if you would not limit the list. "end" tells you how many items there are in the list that is part of the response.

I'll probably add a description to the "end" property to make it easier to understand.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
Okay, thanks. I could understand the total starting from 1 but as "start" starts from 0 I was expecting "end" to end 596.
Image
AWXi - Ajax web interface. Wiki
Reply
Yeah like I said the naming choice "end" is not very good but it has been there since the beginning of JSON-RPC.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
Hi Montellese,

I've added support to my app for playing internet streams, and I noted that the JSON API ("Player.GetItem) does not retrieve the title or the genre. On the HTTP API (command=GetCurrentlyPlaying) however these are correctly retrieved.

Here is a response from JSON:
{
"id": 2097173,
"jsonrpc": "2.0",
"result": {
"item": {
"album": "",
"albumartist": "",
"albumid": -1,
"artist": "",
"artistid": -1,
"comment": "",
"duration": -1,
"fanart": "special://masterprofile/Thumbnails/Music/Fanart/ffffffff.tbn",
"file": "http://50.117.115.211:80",
"genre": "",
"label": "(#1 - 1415/5000) idobi Radio: New. Music. Unfiltered. idobi.com",
"lyrics": "",
"playcount": 0,
"rating": 48,
"thumbnail": "",
"title": "",
"track": 0,
"type": "song",
"year": 0
}
}
}

and here is the same media info retrieved with HTTP API command GetCurrentlyPlaying:

Filename:http://50.117.115.211:80/
PlayStatusTonguelaying
SongNo:0
Type:Audio
Title:Transit - The Answer Comes In Time
Genre:Alternative, Pop, Rock
URL:
Lyrics:
Samplerate:44
ThumbBig GrinefaultAlbumCover.png
Time:01:23
Duration:
Percentage:-2147483648
File size:-1
Changed:False
Reply
That's because internally XBMC is not always very consistent about storing certain information which does not come from its databases (so e.g. from addons, streams etc).

Is there an easy way for me to reproduce this by using a certain addon or in some other way?
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
Montellese Wrote:Is there an easy way for me to reproduce this by using a certain addon or in some other way?

Ok one important piece of information I left out was that I play the file by adding it to the audio playlist. The reason thats important to note, is that I just tested playing with Player.Open using the file instead of playlist position and found that the info is even worse (everything empty). So it looks like there are 2 related bugs here.

Ok so let me give you the different test scenarios

Scenario 1
To start the stream from a playlist, create a m3u file (such as Stream.m3u). Use a text editor and just add in the following stream:
http://216.172.153.242:80
Make sure the Steam.m3u file is in your xbmc music playlist directory under userdata. You should then be able to run the playlist in XBMC, under music->files->playlists

Player.GetItem gives me the following:

{
"id": 2097173,
"jsonrpc": "2.0",
"result": {
"item": {
"file": "",
"label": "",
"thumbnail": "",
"type": "unknown"
}
}
}

The following HTTP API command run in a browser on the xbmc localhost still gives the correct info:
http://localhost:8080/xbmcCmds/xbmcHttp?...Playing();

Scenario 2 using JSON
This scenario should give you the same result as Scenario 1
run the following JSON command to start playing the stream:
{"method":"Player.Open","id":44,"jsonrpc":"2.0","params":{"item":{"file":"http://216.172.153.242:80"}}}

Scenario 3 - JSON through the playlist
Run the following 3 JSON commands to play through the playlist:
a)
{"method":"Playlist.Clear","id":37,"jsonrpc":"2.0","params":{"playlistid":0}}
b)
{"method":"Playlist.Add","id":36,"jsonrpc":"2.0","params":{"item":{"file":"http://216.172.153.242:80"},"playlistid":0}}
c)
{"method":"Player.Open","id":44,"jsonrpc":"2.0","params":{"item":{"position":0,"playlistid":0}}}

I use the following to get the details through JSON in all scenarios (I test using Simple REST client in Google Chrome):
{"method":"Player.GetItem","id":2097173,"jsonrpc":"2.0","params":{"playerid":0,"properties":["title","artist","albumartist","genre","year","rating","album","track","duration","comment","lyrics","playcount","fanart","runtime","streamdetails","thumbnail","file","artistid","albumid"]}}

Let me know if you need anymore details, and thanks for looking into the issue.
Reply
Another easy way to have empty data is a simple Builtin PlayMedia with any internet stream like an avi or mp3 will return empty data and type unknown.

It should at least fill the File and/or Label.
Reply
Using the Input method how much time should I allow between sends? IE if I want to send Input.Right 6 times how long should I wait between each call? If I go faster will they queue and process when the system can or will some be dropped?
Reply
Tolriq Wrote:Another easy way to have empty data is a simple Builtin PlayMedia with any internet stream like an avi or mp3 will return empty data and type unknown.

It should at least fill the File and/or Label.
Like I said XBMC offers several different ways to start playback of an item. This is because there are several APIs (python, http api, json-rpc, skins, ...) and unfortunately every one of them works differently. Most of them just set the available details in a way that they are accessible to the skinning engine but that requires to retrieve every property with custom code (which is what the HTTP-API does) but with JSON-RPC providing the functionality to specify which properties to retrieve this gets quite a bit more complicated and does not fit into the design of JSON-RPC's code (which works on items like they are returned by the databases etc).

TugboatBill Wrote:Using the Input method how much time should I allow between sends? IE if I want to send Input.Right 6 times how long should I wait between each call? If I go faster will they queue and process when the system can or will some be dropped?
Key presses through JSON-RPC are not queued so you need to make sure not to send them too fast in succession. XBMC reads the key presses everytime it draws a new frame on the screen so the interval depends on how fast XBMC renders your screen. Ideally this is 24 fps but if the hardware XBMC runs on is to slow it could drop further down. You might wanna take a look at how EventClients work because they would be subject to the same problem.

Harriett456 Wrote:Not sure if this has been catered for or if fully on topic but would be nice to have some improved screenshot functions.
There's no such functionality yet so please create a feature request ticket on trac with what functionality/features you would like to see.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
Montellese Wrote:JSON-RPC does not yet provide any filtering functionality but once that's possible I'm sure scripts like watchlist can be improved to only fetch as much data through JSON-RPC as necessary. JSON-RPC is still very young but it's contantly growing (once the feature freeze is over Wink).

But still things can only be optimised so much and people have to keep and mind that a low-end device like an ATV2, an iPad and most embedded devices (compared to a normal computer) does not provide as much power as other systems do. Every system has a drawback, one has a fast boot-time but not much ponies and the other has a longer boot-time but enough power to handle anything you throw at it.

I am just jumping on that discussion. I have been working on an app based on JSON RPC for a few months now (about a year and not finished Confused)
When my app starts i ask for all movies (265 movies).
When working with an XBMC running on osx or win, it s really fast (not more than 2 sec to get the json response).
But recently i bought a ATV2. It runs amazingly well with XBMC. The GUI is even pretty fast.
Now as i am working with the JSON from my ATV2 i can see the difference with querying JSON.
On my atv2 asking for all movies takes up to 20sec.
I now the ATV2 is not as powerful as a PC, but it still seems pretty long to me.
Moreover i was wondering if it could come from the DB query or the JSON construction.
When we enter the movie view in XBMC, is a DB query done at that moment?
I ask cause on my ATV2 opening the movie view takes about 2-5 sec.
So if there is a query DB, we "might" conclude that in the 20sec it takes to send back the JSON result of my query, about 10 to 15 sec is used to create the JSON object / translate to string / send.

I now i am speculating but i really hope in a near future we can improve that response time.
The main problem with that in my app is not that loading the library takes a long time, the problem is that during those 20sec my other calls to XBMC wont get through (querying covers ...)

Anyway thanks a lot for all your work. We can do some amazing things thanks to your work!
Reply
carmenm Wrote:I am just jumping on that discussion. I have been working on an app based on JSON RPC for a few months now (about a year and not finished Confused)
When my app starts i ask for all movies (265 movies).
When working with an XBMC running on osx or win, it s really fast (not more than 2 sec to get the json response).
But recently i bought a ATV2. It runs amazingly well with XBMC. The GUI is even pretty fast.
Now as i am working with the JSON from my ATV2 i can see the difference with querying JSON.
On my atv2 asking for all movies takes up to 20sec.
I now the ATV2 is not as powerful as a PC, but it still seems pretty long to me.
Moreover i was wondering if it could come from the DB query or the JSON construction.
When we enter the movie view in XBMC, is a DB query done at that moment?
I ask cause on my ATV2 opening the movie view takes about 2-5 sec.
So if there is a query DB, we "might" conclude that in the 20sec it takes to send back the JSON result of my query, about 10 to 15 sec is used to create the JSON object / translate to string / send.
What does your request look like, specifically which properties do you request? If you request either one of the following properties it is the DB query that causes the problems: set, setid, cast, resume (maybe I forgot one). If you don't specify any of these properties the response should take about the same time as loading the movie list in XBMC GUI. Once you specify at least one of the mentioned properties, the response time will skyrocket because JSON-RPC needs to perform at least three extra DB queries for every movie retrieved. So if you got 100 movies instead of doing a single DB query you will do 1 + 3 * 100 = 301 DB queries. Therefore it will take that long to respond.

carmenm Wrote:I now i am speculating but i really hope in a near future we can improve that response time.
The main problem with that in my app is not that loading the library takes a long time, the problem is that during those 20sec my other calls to XBMC wont get through (querying covers ...)
Yeah our current implementation of the webserver only allows 1 connection at the time which is a bit stupid. After Eden I will change this to allow 4 simultaneous connections (doesn't sound like a lot but it makes a huge difference) so even if you are waiting on a JSON-RPC response that takes a few seconds you will be able to do other JSON-RPC requests and download thumbnails etc in the mean time.

EDIT: Sorry the above information was not 100% accurate. Our implementation allows multiple simultaneious file accesses (like downloading thumbnails etc) but once a request to something like HTTP-API or JSON-RPC (which has dynamic "content") is done that request will block any other requests until it has finished.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
Montellese Wrote:What does your request look like, specifically which properties do you request? If you request either one of the following properties it is the DB query that causes the problems: set, setid, cast, resume (maybe I forgot one). If you don't specify any of these properties the response should take about the same time as loading the movie list in XBMC GUI. Once you specify at least one of the mentioned properties, the response time will skyrocket because JSON-RPC needs to perform at least three extra DB queries for every movie retrieved. So if you got 100 movies instead of doing a single DB query you will do 1 + 3 * 100 = 301 DB queries. Therefore it will take that long to respond.
That makes sense and might just be it as i know i ask for cast (to create a DB of actors). Will try that tomorrow, and share the result.
And it appears i will have to find another way to create an actor DB.

Montellese Wrote:Yeah our current implementation of the webserver only allows 1 connection at the time which is a bit stupid. After Eden I will change this to allow 4 simultaneous connections (doesn't sound like a lot but it makes a huge difference) so even if you are waiting on a JSON-RPC response that takes a few seconds you will be able to do other JSON-RPC requests and download thumbnails etc in the mean time.
That would REALLY be awesome Big Grin

thank you very much for the answer Montellese (and what a fast answer!)
Reply
On a similar note and probably another silly question by me but how can I get the limit of items?

I'm not at home to test atm but I assume I can use limits start and end. My real question I guess, is how do I know the end without having to do a full call on a library?
Image
AWXi - Ajax web interface. Wiki
Reply
  • 1
  • 114
  • 115
  • 116(current)
  • 117
  • 118
  • 226

Logout Mark Read Team Forum Stats Members Help
JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC8