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.
vidtech Wrote:Hi guys, new round these parts,

Been looking at the methods that have been mapped so far and was wondering if there was any way to navigate the menus of xbmc? - i.e. getting the same result as using up,down, left, right & enter on a keyboard.

Would you consider expanding your ticket to include the implementation of all Action commands? I don't think those 5 commands would be enough to fully control the interfaces. For example, in my experience, you can't close dialogs or navigate back to screens without Back, Close_Dialog, and Parent_Dir. Here is a list of all the ones I have implemented using the current HTTP API interface in my driver (some are redundant with the VideoPlayer/AudioPlayer commands) Looking forward to the day I can abandon the HTTP API...

Code:
Action(1);    ACTION_MOVE_LEFT
Action(2);    ACTION_MOVE_RIGHT
Action(3);    ACTION_MOVE_UP
Action(4);    ACTION_MOVE_DOWN
Action(5);    ACTION_PAGE_UP
Action(6);    ACTION_PAGE_DOWN
Action(7);    ACTION_SELECT_ITEM
Action(9);    ACTION_PARENT_DIR
Action(10);    ACTION_PREVIOUS_MENU
Action(11);    ACTION_SHOW_INFO
    
Action(12);    ACTION_PAUSE
Action(13);    ACTION_STOP
Action(14);    ACTION_NEXT_ITEM
Action(15);    ACTION_PREV_ITEM
Action(16);    ACTION_FORWARD
Action(17);    ACTION_REWIND
    
Action(18);    ACTION_SHOW_GUI
Action(19);    ACTION_ASPECT_RATIO
Action(20);    ACTION_STEP_FORWARD
Action(21);    ACTION_STEP_BACK
Action(22);    ACTION_BIG_STEP_FORWARD
Action(23);    ACTION_BIG_STEP_BACK
Action(24);    ACTION_SHOW_OSD
Action(25);    ACTION_SHOW_SUBTITLES
Action(26);    ACTION_NEXT_SUBTITLE
Action(27);    ACTION_SHOW_CODEC
Action(51);    ACTION_CLOSE_DIALOG
Action(56);    ACTION_AUDIO_NEXT_LANGUAGE
    
Action(58);    REMOTE_0
Action(59);    REMOTE_1
Action(60);    REMOTE_2
Action(61);    REMOTE_3
Action(62);    REMOTE_4
Action(63);    REMOTE_5
Action(64);    REMOTE_6
Action(65);    REMOTE_7
Action(66);    REMOTE_8
Action(67);    REMOTE_9
    
Action(85);    ACTION_TAKE_SCREENSHOT
Action(88);    ACTION_VOLUME_UP
Action(89);    ACTION_VOLUME_DOWN
Action(91);    ACTION_MUTE
Action(110);    ACTION_BACKSPACE
Action(111);    ACTION_SCROLL_UP
Action(112);    ACTION_SCROLL_DOWN
Action(117);    ACTION_CONTEXT_MENU
Action(123);    ACTION_SHOW_OSD_TIME
Action(134);    ACTION_SHOW_VIDEOMENU
Action(135);    ACTION_ENTER
Action(138);    ACTION_NEXT_SCENE
Action(139);    ACTION_PREV_SCENE
Action(199);    ACTION_TOGGLE_FULLSCREEN
wuench Wrote:Would you consider expanding your ticket to include the implementation of all Action commands? I don't think those 5 commands would be enough to fully control the interfaces. For example, in my experience, you can't close dialogs or navigate back to screens without Back, Close_Dialog, and Parent_Dir. Here is a list of all the ones I have implemented using the current HTTP API interface in my driver (some are redundant with the VideoPlayer/AudioPlayer commands) Looking forward to the day I can abandon the HTTP API...

Code:
Action(1);    ACTION_MOVE_LEFT
Action(2);    ACTION_MOVE_RIGHT
Action(3);    ACTION_MOVE_UP
Action(4);    ACTION_MOVE_DOWN
Action(5);    ACTION_PAGE_UP
Action(6);    ACTION_PAGE_DOWN
Action(7);    ACTION_SELECT_ITEM
Action(9);    ACTION_PARENT_DIR
Action(10);    ACTION_PREVIOUS_MENU
Action(11);    ACTION_SHOW_INFO
    
Action(12);    ACTION_PAUSE
Action(13);    ACTION_STOP
Action(14);    ACTION_NEXT_ITEM
Action(15);    ACTION_PREV_ITEM
Action(16);    ACTION_FORWARD
Action(17);    ACTION_REWIND
    
Action(18);    ACTION_SHOW_GUI
Action(19);    ACTION_ASPECT_RATIO
Action(20);    ACTION_STEP_FORWARD
Action(21);    ACTION_STEP_BACK
Action(22);    ACTION_BIG_STEP_FORWARD
Action(23);    ACTION_BIG_STEP_BACK
Action(24);    ACTION_SHOW_OSD
Action(25);    ACTION_SHOW_SUBTITLES
Action(26);    ACTION_NEXT_SUBTITLE
Action(27);    ACTION_SHOW_CODEC
Action(51);    ACTION_CLOSE_DIALOG
Action(56);    ACTION_AUDIO_NEXT_LANGUAGE
    
Action(58);    REMOTE_0
Action(59);    REMOTE_1
Action(60);    REMOTE_2
Action(61);    REMOTE_3
Action(62);    REMOTE_4
Action(63);    REMOTE_5
Action(64);    REMOTE_6
Action(65);    REMOTE_7
Action(66);    REMOTE_8
Action(67);    REMOTE_9
    
Action(85);    ACTION_TAKE_SCREENSHOT
Action(88);    ACTION_VOLUME_UP
Action(89);    ACTION_VOLUME_DOWN
Action(91);    ACTION_MUTE
Action(110);    ACTION_BACKSPACE
Action(111);    ACTION_SCROLL_UP
Action(112);    ACTION_SCROLL_DOWN
Action(117);    ACTION_CONTEXT_MENU
Action(123);    ACTION_SHOW_OSD_TIME
Action(134);    ACTION_SHOW_VIDEOMENU
Action(135);    ACTION_ENTER
Action(138);    ACTION_NEXT_SCENE
Action(139);    ACTION_PREV_SCENE
Action(199);    ACTION_TOGGLE_FULLSCREEN

For those you can use eventserver Smile Works well even if all JSON would be better.

I think the full list is needed, as all users will need some specific buttons Smile

For example i need playdrive, eject, myvideo, mymusic ... Smile
Hi guys,

I tried to add some mp3-streams to the playlist with this command
Code:
curl -s -S -m 3 -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlaylist.Add", "params": { "file" : "/home/xbmc/.xbmc/userdata/playlists/music/radio.m3u"}, "id": 1}' http://192.168.0.24:8080/jsonrpc
OK, this works but the m3u is add not the streams inside and there is no label.
After this I tried to add the streams one by one with this command:
Code:
curl -s -S -m 3 -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlaylist.Add", "params": { "file" : "http://gffstream.ic.llnwd.net/stream/gffstream_mp3_w49a", "label" : "Bremen 4"}, "id": 1}' http://192.168.0.24:8080/jsonrpc
The stream is added but again without a label.

Is it possible with the json-interface to:
  1. Add a playlistfile (m3u, pls) as a new playlist or the songs inside to an existing playlist?
  2. How could I add a label to the streams?
if you want to add the content of a playlist you should do
Code:
curl -s -S -m 3 -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlaylist.Add", "params": { "playlist-file" : "/home/xbmc/.xbmc/userdata/playlists/music/radio.m3u"}, "id": 1}' http://192.168.0.24:8080/jsonrpc
IIRC
A person using the latest git version of XBMC was having problems with PseudoTV. Looking at his log, I see that the duration field was not returned in the GetDirectory JSON call that's done. The field is specified in the call along with others, and the others return properly. Has the name of this field changed? If it should work the same as it does in Dharma, I will file a bug report.
Jason102 Wrote:A person using the latest git version of XBMC was having problems with PseudoTV. Looking at his log, I see that the duration field was not returned in the GetDirectory JSON call that's done. The field is specified in the call along with others, and the others return properly. Has the name of this field changed? If it should work the same as it does in Dharma, I will file a bug report.

Fairly certain it has not changed, is it just PseudoTV or is it all add-ons? Because if its just PseudoTV it could be that it has stopped giving that info?
I honestly don't know whether other plugins have this issue or not. Here is the code:

Code:
json_query = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "%s", "media": "%s", "recursive": "%s", "fields":["duration","tagline","showtitle","album","artist","plot"]}, "id": 1}' % ( self.escapeDirJSON( dir_name ), media_type, recursive )

json_folder_detail = xbmc.executeJSONRPC(json_query)
self.log(json_folder_detail)

The results in the log show that, in Dharma, duration is properly returned as an int value along with the appropriate other fields (depending on the media type, of course). In the repository XBMC, though, the other fields appear but duration is not there.
Jason102 Wrote:I honestly don't know whether other plugins have this issue or not. Here is the code:

Code:
json_query = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "%s", "media": "%s", "recursive": "%s", "fields":["duration","tagline","showtitle","album","artist","plot"]}, "id": 1}' % ( self.escapeDirJSON( dir_name ), media_type, recursive )

json_folder_detail = xbmc.executeJSONRPC(json_query)
self.log(json_folder_detail)

The results in the log show that, in Dharma, duration is properly returned as an int value along with the appropriate other fields (depending on the media type, of course). In the repository XBMC, though, the other fields appear but duration is not there.

Open a ticket with full Debug Log and if possible a test script
@topfs2
Thanks, this works fine Smile

But I have an other question:

With a fresh booted xbmc, I add to my empty playlist eight streams/songs, this works now (many thanks). If I try to play the first song I use this json-rpc commands:
Code:
curl -s -S -m 3 -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlaylist.Play", "params": { "songid" : "0"}, "id": 1}' http://192.168.0.24:8080/jsonrpc
or this one
Code:
curl -s -S -m 3 -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlaylist.Play", "params": "0", "id": 1}' http://192.168.0.24:8080/jsonrpc
Both results with an ""Failed to execute method" (same with other song-ids). What should I do?
Generally both of these requests should be valid. If you provide no "songid" field or 0 as a value (which is the case in your example) it should simply start playing the playlist. At a quick glance I couldn't figure out how AudioPlaylist.Play could (in any case) return "Failed to execute method" so I'll have to take a closer look when I get home today.

Did you check if the playlist actually contained the eight streams/songs you added using json rpc (with AudioPlaylist.GetItems())?
Hi everyone,

i've just stumbled over a strange bug:
"Player.GetActivePlayers" times out if an addon has the virtual keyboard opened.

How to reproduce:
- Take an addon with an integrated search feature, like YouTube
- In the youtube addon, got to Search->Search...
- the virtual keyboard will pop up.
- now, with the keyboard opened, use your favorite script / curl whatever and do a Player.GetActivePlayers => timeout.
- close the keyboard and everything's back to normal.

I've tested this with different addons, same result.

I don't know if this is JSON or rather core related (suspect the later one), but i thought i'd post it here anyway.

Edit:
Tested with XBMC 10.0 running on OS X
grywnn Wrote:Hi everyone,

i've just stumbled over a strange bug:
"Player.GetActivePlayers" times out if an addon has the virtual keyboard opened.

Thanks for the detailed description. Could you
1. create a bug ticket on trac for this?
2. turn on debug logging (Settings -> System -> Debugging), re-run the steps you described to reproduce the problem and then attach the debug log to the trac ticket?

That would help a lot to narrow down the problem. Thanks.
topfs2,

How hard would it be to implement a function that will allow users to retrieve all audio devices and reconfigure them?
Montellese Wrote:1. create a bug ticket on trac for this?
2. turn on debug logging (Settings -> System -> Debugging), re-run the steps you described to reproduce the problem and then attach the debug log to the trac ticket?
Done.
@Montelese
I do the following:
Code:
curl -s -S -m 3 -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlaylist.Add", "params": { "playlist-file" : "/home/xbmc/.xbmc/userdata/playlists/music/Radio.m3u"}, "id": 1}' http://192.168.0.24:8080/jsonrpc
Result:
Code:
{
   "id" : 1,
   "jsonrpc" : "2.0",
   "result" : "OK"
}

and the result from:
Code:
curl -s -S -m 3 -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlaylist.GetItems", "params": { "fields": ["title","artist"] }, "id": 1}' http://192.168.0.24:8080/jsonrpc
is
Code:
{
   "id" : 1,
   "jsonrpc" : "2.0",
   "result" : {
      "end" : 8,
      "items" : [
         {
            "file" : "http://rs20.stream24.org:8000/stream",
            "label" : "FFN"
         },
         {
            "file" : "http://mp3.webradio.rockantenne.de:80",
            "label" : "Rock Antenne"
         },
         {
            "file" : "http://87.118.78.7:8030",
            "label" : "TOP 100 Station"
         },
         {
            "file" : "http://ndr.ic.llnwd.net/stream/ndr_ndr2_hi_mp3",
            "label" : "NDR2"
         },
         {
            "file" : "http://gffstream.ic.llnwd.net/stream/gffstream_mp3_w49a",
            "label" : "Bremen 4"
         },
         {
            "file" : "http://62.27.26.27:80/sunshinelive/livestream.mp3",
            "label" : "Sunshine Live"
         },
         {
            "file" : "http://ndr.ic.llnwd.net/stream/ndr_n-joy_hi_mp3",
            "label" : "N-Joy"
         },
         {
            "file" : "http://ice.streaming.spacenet.de:80/radio21",
            "label" : "Radio 21"
         }
      ],
      "start" : 0,
      "total" : 8
   }
}

so I try to play:
Code:
curl -s -S -m 3 -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlaylist.Play", "params": { "songid" : "0"}, "id": 1}' http://192.168.0.24:8080/jsonrpc
with the result
Code:
{
   "error" : {
      "code" : -32100,
      "message" : "Failed to execute method."
   },
   "id" : 1,
   "jsonrpc" : "2.0"
}
If I load a playlist with the frontend and the playlist is open, the play-command works...