• 1
  • 125
  • 126
  • 127(current)
  • 128
  • 129
  • 226
JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC
Tuesday, May 1st 2012:
Commit: 5cc59fd88149927ae708
  • added "lastplayed" property for songs
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
With streaming audio the skins can pick up additional information (such as artist and song name). Is it possible to make that available? Atm all you get is the name of the stream as the label.
Image
AWXi - Ajax web interface. Wiki
Reply
With what version of XBMC and the JSON-RPC API did you try this? I added the following commit a while back which should provide more info for non-library items through Player.GetItem: https://github.com/xbmc/xbmc/commit/73fd...32648b3110
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
This is in Eden. I just tried it in Frodo and get the same. For reference:
Code:
{"jsonrpc": "2.0", "method": "Player.GetItem", "params": { "properties": ["title", "album", "artist", "duration", "thumbnail", "file", "fanart", "streamdetails"], "playerid": 0 }, "id": 1}
Code:
{"id":1,"jsonrpc":"2.0","result":{"item":{"fanart":"special://masterprofile/Thumbnails/Video/Fanart/515043c5.tbn","file":"shout://streamer-dtc-aa01.somafm.com:80/stream/1018","label":"SomaFM Groove Salad","thumbnail":"","title":"","type":"unknown"}}}
Image
AWXi - Ajax web interface. Wiki
Reply
Friday, May 4th 2012:
Commit: 0bd7924d87f00059a9b4
  • added SetArtistDetails, SetAlbumDetails and SetSongDetails to the AudioLibrary namespace
  • added SetMovieDetails, SetTVShowDetails. SetEpisodeDetails and SetMusicVideoDetails to the VideoLibrary namespace
  • added RemoveMovie, RemoveTVShow, RemoveEpisode and RemoveMusicVideo to the VideoLibrary namespace

I'll update the wiki page on JSON-RPC API v5 ASAP but make sure to take a close look at the JSON schema for the SetFooDetails methods so you don't mess up your (and possibly other people's) libraries Wink
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
Nice. Fingers crossed for webserver: image transformation handler soon Smile

I'm using Frodo with Firefox and I think the Content-Type change has broken things. It appears that Firefox adds "; charset=UTF-8" to the Content-Type. Bug report. Chrome and IE don't do this and all the JSONRPC requests work fine. Same thing in Firefox gives:
Code:
NetworkError: 415 Unsupported Media Type
from FireBug. Anything you can do on the web server end because Mozilla won't?

Did you get a chance to check on the details of audio web streams whilst I'm here?
Image
AWXi - Ajax web interface. Wiki
Reply
(2012-05-04, 18:06)Mizaki Wrote: Nice. Fingers crossed for webserver: image transformation handler soon Smile
jmarshall claimed that PR and will adjust it's implementation so might still be a while.

(2012-05-04, 18:06)Mizaki Wrote: I'm using Frodo with Firefox and I think the Content-Type change has broken things. It appears that Firefox adds "; charset=UTF-8" to the Content-Type. Bug report. Chrome and IE don't do this and all the JSONRPC requests work fine. Same thing in Firefox gives:
Code:
NetworkError: 415 Unsupported Media Type
from FireBug. Anything you can do on the web server end because Mozilla won't?
Should be fixed with https://github.com/xbmc/xbmc/commit/75fd...cb9784be76

(2012-05-04, 18:06)Mizaki Wrote: Did you get a chance to check on the details of audio web streams whilst I'm here?
As I don't use any audio web streams or similar addons it always takes me a while to look into those things.
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
That's great, thanks. I don't use them either but Martijn was bugging me Smile
Image
AWXi - Ajax web interface. Wiki
Reply
I'm having trouble finding out how the websocket functionality works.
Maybe it lacks documentation because websocket support is pretty new (and maybe unstable), but it would be great if someone could point me in the right direction.

Thusfar I've got the following:

Code:
var xbmcSocket = new WebSocket('ws://localhost:9090/jsonrpc');
xbmcSocket.onopen = function() {
    console.log('xbmcSocket.open');
};
xbmcSocket.onmessage = function(msg) {
    console.log('xbmcSocket.onmessage', msg);
};
So far so good: I now receive XBMC events.

Now I would also like to send commands using the websocket. So my initial though was:
Code:
xbmcSocket.send({
    "id": 1,
    "jsonrpc": "2.0",
    "method": "JSONRPC.Introspect"
});
However, this gives the following parse error:
Code:
{
    "error": {
        "code": -32700,
        "message": "Parse error."
    },
    "id": null,
    "jsonrpc": "2.0"
}
Reply
You are probably the first to try and use the new websocket functionality (after me) so first thanks for the feedback. Have you tried other JSON-RPC methods like JSONRPC.Ping etc? I have to admit that JSONRPC.Introspect is a bit of a loose candidate depending on the browser/websocket-implementation is used because of the huge amount of data it returns. During my testing I found out that there are browsers who can handle literally any amount of result data you throw at them while others have a fixed limit (which is pretty stupid considering that WebSocket supports fragmented messages).

Thanks again for the feedback.
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
Thanks for the fast response.
I did try other methods. They all give the same parse error.

Is there any way I can provide more information to make the debugging easier? I'm not sure how to debug websockets.
Reply
Neither am I. I just ran latest XBMC (from master not a nightly build, but shouldn't make a difference) and used the websocket demo on websocket.org, opened a websocket to XBMC and ran JSONRPC.Ping, JSONRPC.Version and VideoLibrary.GetMovies without a problem.

EDIT: What browser are you using and are you using any framework for websockets?
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
When using Firefox, I can't get the websocket.org demo to connect to the websocket. In Chrome I can.

Via the demo I found out I had to send the JSON encoded string instead of the actual object (I tried this before using the Introspect method, but this gave me the error "Received unexpected continuation frame."):
Code:
var xbmcSocket = new WebSocket('ws://localhost:9090/jsonrpc');
xbmcSocket.onopen = function() {
    console.log('xbmcSocket.open');
    xbmcSocket.send(JSON.stringify({
        "id": 1,
        "jsonrpc": "2.0",
        "method": "JSONRPC.Ping"
    }));
};
xbmcSocket.onmessage = function(msg) {
    console.log('xbmcSocket.onmessage', msg);
};

This does work!

BTW: The error "Received unexpected continuation frame." also occurs when I start playing a movie.
Reply
That's funny. I was just about to post I was having problems. I've been trying on and off for a few days, I'm doing basically the same thing but I don't get a connection. It tries to open and then after a while I get a closed message and error "Firefox can't establish a connection to the server at ws://10.0.0.101:9090/jsonrpc". Here is the simple code:
Code:
        wsListener: function() {
            if ("WebSocket" in window) {
                
                var wsConn = 'ws://' + location.hostname + ':9090/jsonrpc';
                console.log(wsConn);
                var ws = new WebSocket(wsConn);
                console.log(ws);
                ws.onopen = function (e) {
                    console.log('socket open');
                    ws.send('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": {"properties" : ["thumbnail"]}, "id": 1}');
                };
                ws.onerror = function (err) {
                    console.log(err);
                };
                ws.onmessage = function (e) {
                    console.log(e.data);
                };
                ws.onclose = function (e) {
                    console.log('socket close');
                };
            };
        }
I can't see what I'm doing wrong. Seems rather simple... I've allowed everything in network just in case. Any ideas? I've tried FF and Chrome.

EDIT: Just thought I'd try the websocket.org demo. Works in Chrome but not in FF. Error in log:
Code:
10:39:44 T:2874841968    INFO: WebSocket [RFC6455]: invalid "connection" received
10:39:44 T:2874841968    INFO: WebSocket: No frame expected in the current state

EDIT, EDIT: Okay and now Chrome is working fine. Maybe because I just allowed UPnP access?

I'll leave all this here for any searchers it might help.
Image
AWXi - Ajax web interface. Wiki
Reply
Ah right I thought the websocket send method would take care of the stringification of the JSON object. Yes a websocket is just an extended TCP socket so you'll need to pass in everything as a string.

Back when I implemented this there was no browser who supported the final RFC6455 implementation yet so I could only test against the latest draft. Maybe there's a bug in there.

The only thing you should have to enable in the settings is "Allow programs on this system to control XBMC" (and "Allow programs on other systems to control XBMC" if that's what you want)).
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
  • 1
  • 125
  • 126
  • 127(current)
  • 128
  • 129
  • 226

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