Kodi Community Forum
Release Library to query xbmc via websockets - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Web Interfaces (https://forum.kodi.tv/forumdisplay.php?fid=156)
+---- Thread: Release Library to query xbmc via websockets (/showthread.php?tid=178438)



Library to query xbmc via websockets - D0nR0s4 - 2013-11-19

Hi,
I posted this over in a thread in Supplementary Tools, but I think this might be pretty useful here, too.
(I hope noone mistakes this for spamming, if it is, I would like to ask one of the mods to move the other thread from there to here. Thanks)

This is a library some of you who want to write web-interfaces for xbmc might like to use.
It allows for very easy use of xbmcs JSONRPC api via websockets.

It is as simple as including a single .js file on your site and then doing something like this:

Code:
var connection = xbmc(window.location.hostname, 9090);
connection.run('VideoLibrary.GetMovies')(['title', 'rating', 'year'], {"start" : 0, "end": 2}, handleMovies);

Where handleMovies is a function which does something with the query result.

I hope this helps someone, and I would love to hear some feedback on this.


RE: Library to query xbmc via websockets - danmedhurst - 2013-11-23

I Might be being dumb but why is this better than just sending a JSON query via the API?


RE: Library to query xbmc via websockets - D0nR0s4 - 2013-11-23

This is actually sending a json query to the api and receiving a result. But currently (at least as far as I was able to tell), most web interfaces use jquery or something similar to query via ajax and then handle the response. I think (unless I missed something), that this solution saves lines of code within the interfaces main js files.


RE: Library to query xbmc via websockets - danmedhurst - 2013-11-30

(2013-11-23, 23:40)D0nR0s4 Wrote: This is actually sending a json query to the api and receiving a result. But currently (at least as far as I was able to tell), most web interfaces use jquery or something similar to query via ajax and then handle the response. I think (unless I missed something), that this solution saves lines of code within the interfaces main js files.

Cool.. so i use a web interface that i've written myself to query the sql db and then play the movies using json commands.. but when i issue the command i end up on a white page with a string result for the command.. does this return something nicer?


RE: Library to query xbmc via websockets - D0nR0s4 - 2013-12-04

Hey, could you show me what exactly you are doing, or how you are calling the lib?


RE: Library to query xbmc via websockets - danmedhurst - 2013-12-07

(2013-12-04, 13:00)D0nR0s4 Wrote: Hey, could you show me what exactly you are doing, or how you are calling the lib?

I'm sending this command from a hyperlink :

http://192.168.1.68:81/jsonrpc?request={%20%22jsonrpc%22:%20%222.0%22,%20%22method%22:%20%22Player.Open%22,%20%22params%22:%20{%20%22item%22:%20{%20%22file%22:%20%22smb://DAN-NAS/Movies/Crime/Running%20Scared%20[2006%20BluRay].mkv%22%20}%20},%20%22id%22:%201%20}