View Full Version : Retrieving Player data

2007-08-07, 22:25
What is the correct way of retrieving player data from one of the SlimServers?

I looked at both SlimDiscovery and SlimBrowser but didn't find anything I could use.

Is there a global object which stores all SlimServers?

2007-08-07, 23:27
> What is the correct way of retrieving player data from one of the
> SlimServers?

What kind of data do you want to know? Jive is using the CLI (documented in the help section of slimserver) over a JSON/RPC interface. Any command found in the CLI can be used.


2007-08-08, 06:49
There are already some Lua classes present which are used to retrieve data:


The applet SlimDiscover searches for active Slimservers and lists them in the main menu of jive (using jive.slim.SlimServers).

The applet SlimBrowser takes a Player object as parameter and then shows a control menu for this particular browser (using jive.slim.Player).

I want to access that data the same data.

I was expecting that there exists a global variable / table which stores all SlimServers or even Player objects.
But I didn't find anything yet.

Does something like this exist already?

2007-08-08, 10:48
Its possible to get a list of server objects using:


Edit - actually thats an itterator - so I'm using this to find a server at present:

for _, s in appletManager:getApplet("SlimDiscovery"):getSlimServers():servers() do
self.server = s

Richard has probably got a better way..

2007-08-08, 14:45
So there is a list of servers, each having a list of players.

From the SlimDiscovery applet, you can get the list of servers (class jive.slim.SlimServers), from which you can get an iterator over the servers. There's currently no way to get to the players :)

But we can add it. Ideally what would you like ?


2007-08-09, 00:34
Triode posted a nice workaround. Didn't try it yet but sounds ok for now.

A better solution could be to have a global variable "slimManager"
and move all functionality which currently is in the SlimDiscovery Applet to that manager. (Searching for SlimServers and Players)

SlimDiscovery applet then should use slimManager to update the Jive menus.

Some methods slimManager should have:

- Retrieve number of active SlimServers
- Retrieve a list of SlimServers and each SlimServer knows its Players
- subscribe/unsubscribe to SlimServer started/stopped events
- subscribe/unsubscribe to Player connect/disconnect events
- get specific SlimServer by ID/Name/IP
- find a Player and the related SlimServer by Player Name / IP

This way all applets would have access to the same functionality without going through the extra step of SlimDiscovery and some extra code.

What do you think?

2007-08-09, 14:35
This opens the question about inter-applet communication. I added the appletManager:getApplet() as a quick fix for this, but wonder if we should have a more structure api including introspection.

Finding out about slimserver, players, etc. is a special case, and the suggestion of a slimManager seems a good one. However I would like to keep this functionality contained in an applet, maybe this should be an extension of the SlimDiscovery applet.

Applets should also be able to discover the currently selected player, for example the screensaver needs to know the player state (playing, paused, etc).


2007-08-10, 14:02
getApplet works, but constructions like


are dangerous because getApplet will return nil if ever the applet is not loaded... But the whole point of keeping SlimDiscovery an applet (and probably why you want the functionality contained in an applet, Richard), is to disable the applet.

That means no matter we do as API and/or introspective mechanism, the caller will have to check the applet it needs was loaded.

So getApplet works as a mechanism IMHO as well as any other.

SlimDiscovery could it's true propose simpler APIs for servers and players, including current one.


2007-08-17, 06:28
Now to actually retrieve data like current song title, artist, artwork I have to use the RequestCLI and request the data from the server?

I didn't find any simple API function to retrieve that data from the player or server objects.