Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Junior Member
    Join Date
    Jun 2017
    Posts
    7

    Plug-in menu item

    Hello,

    Logitech Media Server version:
    7.8.0

    Scenario:
    When viewing an album with an iPad, pressing and holding an album brings up a context menu, and tapping the same album brings up a page menu.

    For a particular menu item, I would like to find a way to either:
    - set the menu item's nextWindow field to one value when it is viewed as a context menu, and to another value when it is viewed as a page menu.
    or:
    - omit the menu item when it is viewed as a page menu.

    Is there any publicly available documentation that may be relevant?

    Thank you for reading.

  2. #2
    Senior Member pippin's Avatar
    Join Date
    Oct 2007
    Location
    Berlin
    Posts
    14,127
    I'm not sure I fully understand what you are trying to do. Could you maybe give an example?
    ---
    learn more about iPeng, the iPhone and iPad remote for the Squeezebox and
    Logitech UE Smart Radio as well as iPeng Party, the free Party-App,
    at penguinlovesmusic.com
    New: iPeng 9, the Universal App for iPhone, iPad and Apple Watch

  3. #3
    Senior Member pippin's Avatar
    Join Date
    Oct 2007
    Location
    Berlin
    Posts
    14,127
    Generally, you can define any menu item in a plugin, all menus are stateful, a set of parameters defining the menu are specified by the plugin and returned to the plugin when an action is being called.
    ---
    learn more about iPeng, the iPhone and iPad remote for the Squeezebox and
    Logitech UE Smart Radio as well as iPeng Party, the free Party-App,
    at penguinlovesmusic.com
    New: iPeng 9, the Universal App for iPhone, iPad and Apple Watch

  4. #4
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,757

    Plug-in menu item

    > For a particular menu item, I would like to find a way to either:
    > - set the menu item's nextWindow field to one value when it is viewed as
    > a context menu, and to another value when it is viewed as a page menu.


    You can define two separate entry points for the menu, which then call
    the main routine with a flag whether it's supposed to be a context menu
    or not.

    --

    Michael

  5. #5
    Junior Member
    Join Date
    Jun 2017
    Posts
    7
    Thank you for your responses,

    Quote Originally Posted by pippin View Post
    Could you maybe give an example?
    Yes, I am defining a menu item similar to this:
    Code:
    {
    	type => 'link',
    	name => 'Add Album to My Albums',
    	url => sub {
    		my ($client, $callback, $parameter, $argument) = @_;
    		# code to add the album to My Albums
    		$callback->();
    	},
    	nextWindow => $nextWindow
    }
    Using an iPad, when pressing and holding an album, the menu item appears in a context menu:
    Name:  contextMenu.jpg
Views: 97
Size:  22.2 KB

    and when tapping the same album, the menu item appears in a page menu:
    Name:  pageMenu.jpg
Views: 96
Size:  109.8 KB

    I am interested in finding information about how $nextWindow can be set to 'parent' in the context menu, and set to 'refresh' in the page menu.


    Quote Originally Posted by mherger View Post
    >You can define two separate entry points for the menu, which then call
    the main routine with a flag whether it's supposed to be a context menu
    or not.
    Is there any publicly available documentation describing the definition of entry points and the flag specifying a context menu?

    Thank you.

  6. #6
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,757
    I'm not sure what you actually want to do. Are you implementing your own plugin? Or do you want to modify the current behavior? If you're working on your own code, then it would be helpful to see it in order to understand what you're doing.

    The best we have in terms of documentation is this wiki page: http://wiki.slimdevices.com/index.ph...ePlayInterface. Or the code...
    Michael

    http://www.herger.net/slim-plugins - Spotty, MusicArtistInfo

  7. #7
    Junior Member
    Join Date
    Jun 2017
    Posts
    7
    Thank you for the documentation.

    Quote Originally Posted by mherger View Post
    Are you implementing your own plugin? Or do you want to modify the current behavior?
    I want to modify the current behaviour (of a plugin):
    I am continuing development of a plugin started by somebody else, including adding menu items.

    This is a minimalistic representation of the scenario:

    Code:
    package Plugins::ATestPlugin::Plugin;
    use base qw(Slim::Plugin::OPMLBased);
    sub initPlugin {
       $_[0]->SUPER::initPlugin(
          menu => 'extras',
          tag => 'atestplugin',
          feed => {
             name => 'A Test Plugin',
             items => [
                {
                   name => 'Albums',
                   items => [
                      {
                         type => 'playlist',
                         name => 'Album 1',
                         url => sub {
                            my $nextWindow = 'parent'; # or 'refresh'
                            $_[1]->(
                               [
                                  {
                                     type => 'audio',
                                     name => 'Track',
                                  },
                                  {
                                     name => 'Add Album to My Albums',
                                     url => sub {
                                        # code to add album to My Albums
                                        $_[1]->();
                                     },
                                     nextWindow => $nextWindow
                                  }
                               ]
                            );
                         }
                      },
                      {
                         type => 'playlist',
                         name => 'Album 2'
                      }
                   ]
                }
             ]
          }
       );
    }
    sub getDisplayName { 'A Test Plugin' }
    1;
    I am interested in finding a way to set $nextWindow to 'refresh' when the menu item is viewed in the page menu, and 'parent' when the menu item is viewed in the context menu.

  8. #8
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,757
    Oh my... I certainly hope you created that code just to demo something. But even at that it doesn't really make a great job...

    First of all: in that code you don't define any context menu, but only a default handler to define a menu for your plugin, hooked in to the main navigation tree.

    2. naming parameters is obviously optional. But it helps an awful lot understanding what you're dealing with.

    3. break that monster up into pieces, giving good, descriptive names to the various functions (totally optional, but very helpful again)

    4. define the two entry points for the main menu and the context menu.

    5. have those two subs call the previously defined subs with a flag telling the latter whether you're in context menu mode or not.

    If you've followed 2 and three, then step 5 will be quite obvious. Or in your way: the flag would end up in the called sub in $_[2] or $_[3]

    If you need more pointer as to what those parameters might refer to, check out eg. https://github.com/Logitech/slimserv...Plugin.pm#L163
    Michael

    http://www.herger.net/slim-plugins - Spotty, MusicArtistInfo

  9. #9
    Junior Member
    Join Date
    Jun 2017
    Posts
    7
    Thank you for suggesting steps to follow.

    I have updated the test code following steps 2 and 3:
    Code:
    package Plugins::ATestPlugin::Plugin;
    use base qw(Slim::Plugin::OPMLBased);
    sub initPlugin {
       $class = shift;
       $class->SUPER::initPlugin(
          menu => 'extras',
          tag => 'atestplugin',
          feed => {
             name => 'A Test Plugin',
             items => [
                {
                   name => 'Albums',
                   items => [
                      {
                         type => 'playlist',
                         name => 'Album 1',
                         url => \&albumItems,
                         passthrough => []
                      },
                      {
                         type => 'playlist',
                         name => 'Album 2'
                      }
                   ]
                }
             ]
          }
       );
    }
    sub albumItems {
       my ( $client,$callback,$parameter,$passthrough ) = @_;
       my $nextWindow = 'parent';
       $callback->(
          [
             {
                type => 'audio',
                name => 'Track',
             },
             {
                name => 'Add Album to My Albums',
                url => \&addAlbumToMyAlbums,
                passthrough => [],
                nextWindow => $nextWindow
             }
          ]
       );
    }
    sub addAlbumToMyAlbums {
       my ( $client,$callback,$parameter,$passthrough ) = @_;
       # code to add album to My Albums
       $callback->();
    }
    sub getDisplayName { 'A Test Plugin' }
    1;
    Quote Originally Posted by mherger View Post
    4. define the two entry points for the main menu and the context menu.
    Do you know of any code on https://github.com/Logitech/slimserver which demonstrates step 4?

    Thanks.

  10. #10
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,757
    Quote Originally Posted by aux View Post
    Do you know of any code on https://github.com/Logitech/slimserver which demonstrates step 4?
    Hmm... don't know off the top of my head. But you'll have to register a track info menu item like this:

    https://github.com/Logitech/slimserv.../Plugin.pm#L30

    The method called by this would call the common code, modifying what is specific to this use case (nextWindow).
    Michael

    http://www.herger.net/slim-plugins - Spotty, MusicArtistInfo

Posting Permissions

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