Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 10 of 225

Hybrid View

  1. #1
    Senior Member
    Join Date
    Aug 2007
    Location
    Portland, OR, USA
    Posts
    218

    Wanting to port SuperDateTime to Touch - need help

    Hey all,

    Simple: Can you access Plugin routines/data/preferences in SqueezeOS?

    I'm trying to get up to speed on Applet writing - I want to have SuperDateTime on the Touch, simple as that. What I don't want to do is re-write all the downloading and parsing and preference setting that Greg has so masterfully done.

    I have glanced through the plugin documentation, and applet documentation, but it's not really clear to me.

    Can I access a plugin from a LUA program? Plugin functions? Can LUA call Perl routines like C++ can call Fortran?

    What's a good way to access preference data from LUA?

    Thanks!

    -Dan

  2. #2
    Senior Member GoCubs's Avatar
    Join Date
    Apr 2005
    Location
    Chicago, IL
    Posts
    1,569
    Quote Originally Posted by plympton View Post
    Hey all,

    Simple: Can you access Plugin routines/data/preferences in SqueezeOS?

    I'm trying to get up to speed on Applet writing - I want to have SuperDateTime on the Touch, simple as that. What I don't want to do is re-write all the downloading and parsing and preference setting that Greg has so masterfully done.

    I have glanced through the plugin documentation, and applet documentation, but it's not really clear to me.

    Can I access a plugin from a LUA program? Plugin functions? Can LUA call Perl routines like C++ can call Fortran?

    What's a good way to access preference data from LUA?

    Thanks!

    -Dan
    Hey Dan-

    I covered some of this in an email I sent you earlier today, but I think LUA-based plugins have their own settings separate than traditional plugins.

    Yes, LUA can communicate with Perl plugins. In the basic SuperDateTime LUA applet I referred you to it achieves this to retrieve the current weather conditions that the SDT Perl plugin is keeping track of.

    -Greg

  3. #3
    Senior Member erland's Avatar
    Join Date
    Dec 2005
    Location
    Sweden
    Posts
    10,355
    What does SDT expose in the form of CLI/JSON commands to get the data ?
    Which can I trust have a stable interface ? Everything registered with addDispatch ?

    If it only expose simple text or image items it would be nice to integrate this with the "Custom Clock" applet so anyone can design their own screen and decide where to position things and combine it with other data supported by Custom Clock.

    Also, does it send any notifications with notifyFromArray when some value is changed ? This would make it possible to avoid polling from the applet side.
    Erland Isaksson (My homepage)
    (Developer of many plugins/applets (both free and commercial).
    If you like to encourage future presence on this forum and/or third party plugin/applet development, consider purchasing some plugins)
    You may also want to try my Android apps Squeeze Display and RSS Photo Show
    Interested in the future of music streaming ? ickStream - A world of music at your fingertips.

  4. #4
    Senior Member erland's Avatar
    Join Date
    Dec 2005
    Location
    Sweden
    Posts
    10,355
    plympton, you can give it a try in a separate applet first and then maybe we could integrate it in Custom Clock as a second step ?
    Erland Isaksson (My homepage)
    (Developer of many plugins/applets (both free and commercial).
    If you like to encourage future presence on this forum and/or third party plugin/applet development, consider purchasing some plugins)
    You may also want to try my Android apps Squeeze Display and RSS Photo Show
    Interested in the future of music streaming ? ickStream - A world of music at your fingertips.

  5. #5
    Senior Member
    Join Date
    Aug 2007
    Location
    Portland, OR, USA
    Posts
    218
    Quote Originally Posted by erland View Post
    plympton, you can give it a try in a separate applet first and then maybe we could integrate it in Custom Clock as a second step ?
    Can do. I've got an applet reading the data from the JSON interface from SuperDateTime. I'm spending a lot of time getting my head wrapped around LUA & its weirdnesses, as well as the SqueezeOS object model and how it's all put together (praying to the documentation gods isn't working)

    Here's an image of my work-in-progress. It's completely hard-coded for my preferences, but it is getting the data from SuperDateTime (though not using the preferences set in the Web UI)

    PS: The code is embarrassingly awful, so I won't upload it yet.

    -Dan
    Attached Images Attached Images  
    Last edited by plympton; 2010-04-25 at 00:46. Reason: Added Screenshot

  6. #6
    Senior Member GoCubs's Avatar
    Join Date
    Apr 2005
    Location
    Chicago, IL
    Posts
    1,569
    Quote Originally Posted by erland View Post
    What does SDT expose in the form of CLI/JSON commands to get the data ?
    Which can I trust have a stable interface ? Everything registered with addDispatch ?

    If it only expose simple text or image items it would be nice to integrate this with the "Custom Clock" applet so anyone can design their own screen and decide where to position things and combine it with other data supported by Custom Clock.

    Also, does it send any notifications with notifyFromArray when some value is changed ? This would make it possible to avoid polling from the applet side.
    Hi Erland-

    I like the sound of this! I had actually tweaked the custom clock applet to retrieve some SDT content but it would definitely make more sense to have you natively support SDT.

    SDT supports several CLI/JSON commands that basically return the hashes that SDT uses internally. The hashes evolved over time as the plugin grew and might not be the most elegant, but I wouldn't expect them to change other than possible additions. I can also make a cleaner API-specific hash if need be.

    What would you expect to be provided for images? Where/how do I include the image files in the SBS plugin so that applets can access them via some sort of text url?

    I'll try to clean up some API documentation on this.

    I wasn't aware of notifyFromArray. Can you provide an example or point me in the direction of an existing plugin that makes use of this in a similar fashion?

    Thanks
    -Greg

  7. #7
    Senior Member erland's Avatar
    Join Date
    Dec 2005
    Location
    Sweden
    Posts
    10,355
    Quote Originally Posted by GoCubs View Post
    What would you expect to be provided for images?
    A url if it's a image handled by SBS it's enough with the part, if it's an image available someone on Internet I need a complete url including host and port, for for example:
    /plugins/SuperDateTime/html/images/someimage.png
    Or
    http://somesite:1234/folder/someimage.png

    Quote Originally Posted by GoCubs View Post
    Where/how do I include the image files in the SBS plugin so that applets can access them via some sort of text url?
    An image in the folder (inside your plugin dir):
    HTML/EN/html/plugins/SuperDateTime/html/images/someimage.png
    Is available as url:
    http://localhost:9000/plugins/SuperDateTime/html/images/someimage.png

    In this case, since it's a SBS url, it's enough if you provide:
    /plugins/SuperDateTime/html/images/someimage.png


    Quote Originally Posted by GoCubs View Post
    I wasn't aware of notifyFromArray. Can you provide an example or point me in the direction of an existing plugin that makes use of this in a similar fashion?
    Honestly, I'm not 100% sure if this is the correct way, but I know it works because I used it in Custom Clock Helper:
    Code:
    my $data = {
        'attr1' => 'value1',
        'attr1' => 'value2',
    };
    Slim::Control::Request::notifyFromArray(undef,['superdatetime','somethingupdated',$data);
    You can specify a $client object in the first parameter if you only want to send it to a specific player.

    You will also need to add the notification in initPlugin with addDispatch, as this:
    Code:
    Slim::Control::Request::addDispatch(['superdatetime', 'somethingupdated'],[0, 1, 0, undef]);
    The "superdatetime", "somethingupdated" notification about is just an example, you should of course use names that are relevant in your case.

    The notifyFromArray can take any number of parameters, so the above sample with a single data parameter is just an example, in the TrackStat plugin I for example use:
    Code:
    Slim::Control::Request::notifyFromArray($client, ['trackstat', 'changedstatistic', $url, $track->id, $playCount, $lastPlayed]);
    And the corresponding addDispatch call:
    Code:
    Slim::Control::Request::addDispatch(['trackstat', 'changedstatistic', '_url', '_trackid', '_playcount','
    _lastplayed'],[0, 0, 0, undef]);
    Erland Isaksson (My homepage)
    (Developer of many plugins/applets (both free and commercial).
    If you like to encourage future presence on this forum and/or third party plugin/applet development, consider purchasing some plugins)
    You may also want to try my Android apps Squeeze Display and RSS Photo Show
    Interested in the future of music streaming ? ickStream - A world of music at your fingertips.

  8. #8
    Senior Member tcutting's Avatar
    Join Date
    May 2008
    Location
    Southern California, USA
    Posts
    886
    Integration of SDT with Custom Clock would be AWESOME!

Posting Permissions

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