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

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



RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Mizaki - 2012-05-19 21:45

Okay, on the query all artists thing. That's fine but you have to use the GUI which if you want to use XBMC as a music player having to turn on the monitor/TV to get the artist info is a bit of a pain. How easy would it be to make the query all artists a JSONRPC command? Say AudioLibrary.QueryAllArtists.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - jonib - 2012-05-19 22:02

(2012-05-19 21:26)Montellese Wrote:  
(2012-05-19 21:07)jonib Wrote:  So I'm wondering why the Player.OnStop notification is different depending on if I stop a media file manually or if it stops by itself? If a video for example stops by itself I get no title or anything else but if I stop the video I get the title and other useful info.

I'm just guessing here because it's hard to track the timeline of these things down but what probably happens is that if playback stops by itself, the reference to the played item is removed before the JSON-RPC notification is generated so JSON-RPC can't provided that information anymore.
I was afraid of that. Do you think that's something that's going to change or would it need a big redesign of XBMC?

So another thing a discovered while testing the notifications.
If I play a video that's not in the XBMC library the Player.OnPlay and other events include an empty Title property and no other identifiable info so making the event less useful, is it possible to add a path or something?

Thanks for the quick reply.

jonib


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-05-19 22:05

Workaround for not returning an error is in place: https://github.com/xbmc/xbmc/commit/2e75130efa69624c7b75488a3eace9f58f8b0ee7

The problem with invoking things like "query all artist info", "refresh single movie" etc is that they always involve the scanner, its dialog and a scraper and last time I played with invoking those through JSON-RPC it sometimes worked fine, sometimes it crashed and sometimes it messed up my database. IMO it's not that much of a pain to start your monitor/tv once after having scanned all your music and then running "query all artist info". It's not like you have to run it all the time. You scan your music library (for which you might even have to turn your monitor on anyway if you e.g. need to add a new source) and then you run "query all artist info" and you should be golden.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-05-19 22:08

(2012-05-19 22:02)jonib Wrote:  I was afraid of that. Do you think that's something that's going to change or would it need a big redesign of XBMC?
Can you create a bug report for this on Trac? I won't have time to look into it in the next few weeks but it's certainly something that should be fixed.

(2012-05-19 22:02)jonib Wrote:  So another thing a discovered while testing the notifications.
If I play a video that's not in the XBMC library the Player.OnPlay and other events include an empty Title property and no other identifiable info so making the event less useful, is it possible to add a path or something?
Yes those are more or less useless in Eden but should have been improved in the nightly builds (although I haven't tested it because I never watch anything that's not in xbmc's library (except movie traileres)).

EDIT: As an example this is the Player.OnPlay notification for the Expendables 2 trailer:
Code:
{ "jsonrpc": "2.0", "method": "Player.OnPlay",    "params": { "data": { "item": { "type": "movie" }, "player": { "playerid": 1, "speed": 1 }, "title": "The Expendables 2", "year": 2012 }, "sender": "xbmc" }
But obviously if xbmc can't retrieve a valid title for whatever you are watching, JSON-RPC won't be able to provide it in notifications.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Mizaki - 2012-05-19 22:23

Okay.

Can you let us know when the notifications are considered working again with AE? No mute notifications and none when changing the volume within XBMC. Oddly I get notifications on volume change when using JSONRPC command.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-05-19 22:28

AE has broken a lot of notifications and I still need gnif to fix those (especially the ones involving music playback as he re-wrote the whole music player).


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - jonib - 2012-05-20 03:54

(2012-05-19 22:08)Montellese Wrote:  
(2012-05-19 22:02)jonib Wrote:  I was afraid of that. Do you think that's something that's going to change or would it need a big redesign of XBMC?
Can you create a bug report for this on Trac? I won't have time to look into it in the next few weeks but it's certainly something that should be fixed.
Ticket 13050 created. Hopefully it has all needed info.

jonib


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-05-20 10:48

(2012-05-20 03:54)jonib Wrote:  
(2012-05-19 22:08)Montellese Wrote:  
(2012-05-19 22:02)jonib Wrote:  I was afraid of that. Do you think that's something that's going to change or would it need a big redesign of XBMC?
Can you create a bug report for this on Trac? I won't have time to look into it in the next few weeks but it's certainly something that should be fixed.
Ticket 13050 created. Hopefully it has all needed info.

jonib

And fixed. Was actually easier than I thought. Back when I introduced notifications the old behaviour was the only way but someone must have adjusted/fixed the internal logic in the meantime so now Player.OnStop should always contain details independent of whether playback stops automatically or through user interaction.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - jonib - 2012-05-20 14:13

(2012-05-20 10:48)Montellese Wrote:  
(2012-05-20 03:54)jonib Wrote:  
(2012-05-19 22:08)Montellese Wrote:  Can you create a bug report for this on Trac? I won't have time to look into it in the next few weeks but it's certainly something that should be fixed.
Ticket 13050 created. Hopefully it has all needed info.

jonib

And fixed. Was actually easier than I thought. Back when I introduced notifications the old behaviour was the only way but someone must have adjusted/fixed the internal logic in the meantime so now Player.OnStop should always contain details independent of whether playback stops automatically or through user interaction.
Cool, thanks. Do you know which nightly will include the fix?

jonib


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-05-20 14:41

I'd say the one that is built tomorrow morning (May 21st).


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - joethefox - 2012-05-21 19:56

I have a little problem. When xbmc accesses to the filesystem, and this takes time to respond (such as hard drives in stand-by) the entire xbmc interface stops responding (playback continues smooth) as well as JSON-RPC interface stops responding. When hard drives are awakened everything returns to normal. I can deal this, just to know if something can be done to prevent this behavior.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Livin - 2012-05-21 20:42

(2012-05-19 22:08)Montellese Wrote:  
(2012-05-19 22:02)jonib Wrote:  So another thing a discovered while testing the notifications.
If I play a video that's not in the XBMC library the Player.OnPlay and other events include an empty Title property and no other identifiable info so making the event less useful, is it possible to add a path or something?
Yes those are more or less useless in Eden but should have been improved in the nightly builds (although I haven't tested it because I never watch anything that's not in xbmc's library (except movie traileres)).

EDIT: As an example this is the Player.OnPlay notification for the Expendables 2 trailer:
Code:
{ "jsonrpc": "2.0", "method": "Player.OnPlay",    "params": { "data": { "item": { "type": "movie" }, "player": { "playerid": 1, "speed": 1 }, "title": "The Expendables 2", "year": 2012 }, "sender": "xbmc" }
But obviously if xbmc can't retrieve a valid title for whatever you are watching, JSON-RPC won't be able to provide it in notifications.

I hope you will consider adding some more usable info here. I'd like to track the usage for kids/guest/etc and better info is necessary to do so. Even something simple like passing <filename> as ' title' and properly identifying 'type' as "video file" or "audio file" (identifying anything unknown as "movie" causes tracking problems)

thx!


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-05-21 21:41

(2012-05-21 19:56)joethefox Wrote:  I have a little problem. When xbmc accesses to the filesystem, and this takes time to respond (such as hard drives in stand-by) the entire xbmc interface stops responding (playback continues smooth) as well as JSON-RPC interface stops responding. When hard drives are awakened everything returns to normal. I can deal this, just to know if something can be done to prevent this behavior.
That's because all the filesystem interaction is synchronous with the GUI so if you open a directory in XBMC's file manager the GUI will "freeze" until the whole content of the directory has been read and processed by XBMC. This has nothing to do with JSON-RPC and is a general "flaw" in XBMC's design.

(2012-05-21 20:42)Livin Wrote:  I hope you will consider adding some more usable info here. I'd like to track the usage for kids/guest/etc and better info is necessary to do so. Even something simple like passing <filename> as ' title' and properly identifying 'type' as "video file" or "audio file" (identifying anything unknown as "movie" causes tracking problems)
If JSON-RPC can't determine what kind of item is being played it should return "type": "unknown" unless the addon (or whatever you use to watch content that is not in the library) provides false information which leads to JSON-RPC using that for notifications.

Generally notifications should be as short as possible because they are messages that are "forced" on the client, it's not something a client manually requests. Furthermore they take up the transport medium for the time of the transport and no response to a (manual) request can be sent while a notification is being sent to the client.

That being said I'm always open to specific ideas what could enhance Player notifications for non-library files. When this feature was requested during v3 we narrowed the most important properties down to what JSON-RPC currently sends. For a (non-library) movie the title and year should be enough to identify the movie with google or on IMDb or TMDb if getting more info is that important to a client.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - joethefox - 2012-05-21 21:57

(2012-05-21 21:41)Montellese Wrote:  That's because all the filesystem interaction is synchronous with the GUI so if you open a directory in XBMC's file manager the GUI will "freeze" until the whole content of the directory has been read and processed by XBMC. This has nothing to do with JSON-RPC and is a general "flaw" in XBMC's design.
just because I'm afraid of being unclear: JSON-RPC (at least with http connection) stops responding too and not just the GUI. This is out from your control?


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-05-21 22:41

(2012-05-21 21:57)joethefox Wrote:  just because I'm afraid of being unclear: JSON-RPC (at least with http connection) stops responding too and not just the GUI. This is out from your control?

Currently XBMC's webserver supports 4 simultaneous threads and therefore 4 simultaneous json-rpc requests. But as most json-rpc request require access to XBMC's core functionality it also requires access to methods/processes/information which are blocked by a (long-lasting) filesystem access. Requests like JSONRPC.Ping, JSONRPC.Version etc should still work (as long as you haven't already sent 4 other requests which are blocked because of the filesystem access) but especially player and input interaction etc will not be possible during such a period.