Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 9 of 9
  1. #1
    Junior Member
    Join Date
    Jul 2007
    Posts
    12

    Retrieving Player data

    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?

  2. #2
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,391

    [SlimDevices: Jive] Retrieving Player data

    > 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.

    Michael

  3. #3
    Junior Member
    Join Date
    Jul 2007
    Posts
    12
    There are already some Lua classes present which are used to retrieve data:

    jive.slim.SlimServer
    jive.slim.SlimServers
    jive.slim.Player

    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?

  4. #4
    Senior Member
    Join Date
    Apr 2005
    Posts
    8,410
    Its possible to get a list of server objects using:

    appletManager:getApplet("SlimDiscovery"):getSlimSe rvers():servers()

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

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

    Richard has probably got a better way..
    Last edited by Triode; 2007-08-08 at 10:50.

  5. #5
    Senior Member
    Join Date
    Jun 2005
    Location
    Switzerland
    Posts
    610
    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 ?

    Fred

  6. #6
    Junior Member
    Join Date
    Jul 2007
    Posts
    12
    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?

  7. #7
    Senior Software Engineer - Logitech/Slim Devices
    Join Date
    Apr 2005
    Location
    Ipswich, UK
    Posts
    1,394
    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).

    Richard

  8. #8
    Senior Member
    Join Date
    Jun 2005
    Location
    Switzerland
    Posts
    610
    getApplet works, but constructions like

    appletManager:getApplet("SlimDiscovery"):getSlimSe rvers():servers()

    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.

    fred

  9. #9
    Junior Member
    Join Date
    Jul 2007
    Posts
    12
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •