PDA

View Full Version : My Menu is Never Called



Aesculus
2009-11-21, 09:11
I am trying to add a menu to the extras and it never shows up. The problem is that my routine to add the player menus, 'avpTop', is never called when I show the debug.

I used the OtherPlayers plugin as a sample and it works just fine.




Slim::Control::Request::addDispatch(['avpTop'],[1, 1, 0, \&avpTop]);
Slim::Control::Request::addDispatch(['avpSM'],[1, 1, 0, \&avpSM]);
Slim::Control::Request::addDispatch(['avpRmEq'],[1, 1, 0, \&avpRmEq]);
Slim::Control::Request::addDispatch(['avpDynEq'],[1, 1, 0, \&avpDynEq]);
Slim::Control::Request::addDispatch(['avpNM'],[1, 1, 0, \&avpNM]);
Slim::Control::Request::addDispatch(['avpRes'],[1, 1, 0, \&avpRes]);

# Create AVP menu under extras
$log->debug("Creating menus: ". getDisplayName() . " \n");
my @menu = ({
stringToken => getDisplayName(),
id => 'pluginDenonAvpControl',
weight => 15,
actions => {
go => {
player => 0,
cmd => [ 'avpTop' ],
}
}
});
$log->debug("Calling the plugin menu register". "\n");
Slim::Control::Jive::registerPluginMenu(\@menu, 'extras');




Everything in this routine seems to work fine and shows up in debug.

Any ideas what is wrong and why my 'avpTop' is not being called?

erland
2009-11-22, 22:17
I am trying to add a menu to the extras and it never shows up. The problem is that my routine to add the player menus, 'avpTop', is never called when I show the debug.

I used the OtherPlayers plugin as a sample and it works just fine.

Everything in this routine seems to work fine and shows up in debug.

Any ideas what is wrong and why my 'avpTop' is not being called?

Do you see the Extras menu at all ? If I remember correctly it's hidden by default so if you don't even see the Extras menu you probably just need to enable it on the Controller/Touch/Radio.

avpTop will be called when you enter the menu, is this what you are seeing or don't you even see the menu so you can enter it ?

I'm not sure but I think "player=>0" indicates that you don't want a player to be sent with the command. If this is the case it doesn't match the "addDispatch(['avpTop'],[1, 1, 0, \&avpTop]);" which indicates that the command needs a player as parameter. Try something like this "addDispatch(['avpTop'],[0, 1, 0, \&avpTop]);" and see if it works better.

Aesculus
2009-11-22, 23:32
Erlan: It never shows up at all. I truncated the OtherPlayers plugin down to where it just shows its title menu item in the xtras menu with the following code:



sub initPlugin {
my $class = shift;

$class->SUPER::initPlugin();

# Register dispatch methods for SP menu options
Slim::Control::Request::addDispatch(['opTop'],[1, 1, 0, \&opTop]);

# Create SP menu under Extras
my @menu = ({
stringToken => getDisplayName(),
id => 'pluginOtherPlayers',
weight => 15,
actions => {
go => {
player => 0,
cmd => [ 'opTop' ],
}
}
});
Slim::Control::Jive::registerPluginMenu(\@menu, 'extras');
}

################################################## #############################
# Handlers for SqueezePlay menu integration
################################################## #############################

# Generates the top level menu, which is a list of all other players
sub opTop {
my $request = shift;
my $client = $request->client();


$log->debug("done");
$request->setStatusDone();
}


It shows up just fine. Of course when I select the Other Players menu item it goes off to a never ending loop because I got rid of all the code below it.

I also tried your suggestion by setting the request to 0,1,0 but it did not make any difference.

The only items I know that OtherPlayers plugin uses is the Install.xml, string.txt and plugin.pm.

I patterned my install and plugin exactly the same. The string file was for labels etc.

There is some stuff in a .svn folder under the OtherPlayers plugin but I think thats just baggage.

I am at a loss of why my request is not being processed. I must be missing some additional setting. Check your PM for other information.

erland
2009-11-22, 23:41
There is some stuff in a .svn folder under the OtherPlayers plugin but I think thats just baggage.

Get rid of the .svn directories. They shouldn't cause a problem but you shouldn't have them unless you plan to update new changes from the OtherPlayers plugin svn repository.



I am at a loss of why my request is not being processed. I must be missing some additional setting. Check your PM for other information.

Make sure you don't get any errors at start up, I usually start Squeezebox Server with --d_startup to get some more logging at startup.

Maybe you could post a zip with the non working version of your plugin, so someone can take a look at it ?

Aesculus
2009-11-22, 23:59
Well here are the three files (install, settings and plugin)

They should be in a folder called DenonAvpControl.

Hope someone can figure out where I have gone wrong.

bpa
2009-11-23, 01:41
Whenever I add an Extras menu I also add the following to the install.xml


<playerMenu>PLUGINS</playerMenu>


Not sure if it is needed to for Jive though.

Aesculus
2009-11-23, 06:59
Whenever I add an Extras menu I also add the following to the install.xml


<playerMenu>PLUGINS</playerMenu>


Not sure if it is needed to for Jive though.

Well its not in the OtherPlayers install file which works fine :-)

erland
2009-11-23, 14:23
I get it to show the menu if I remove the following lines:


use Plugins::DenonAvpControl::DenonAvpComms;
use Plugins::DenonAvpControl::Settings;


However, to make it show I need to goto "Settings/Home Menu" on the Controller and enable the "Extras" menu which is disabled by default.

The menu is shown and when I enter it the server logs "Adding menu:" which is inside the avpTop function.

Aesculus
2009-11-23, 14:46
I get it to show the menu if I remove the following lines:


use Plugins::DenonAvpControl::DenonAvpComms;
use Plugins::DenonAvpControl::Settings;


However, to make it show I need to goto "Settings/Home Menu" on the Controller and enable the "Extras" menu which is disabled by default.

The menu is shown and when I enter it the server logs "Adding menu:" which is inside the avpTop function.

Erland: I ran a session a few minutes ago where I deleted the references to those plugins too and it did not show. I attached a very stripped Plugin.PM to this. It should essentially be what you created and will behave the exact same way to show the menu title and then a blank screen with the one debug statement that shows the sub was called.

Can you load this Plugin.PM into your system and try it for me? Also can you try this on a non controller and see if you get the menu within the context menus? ie if you use iPeng by pressing and holding on the player.

I tried it on a SB3 and Boom that had extras already listed. Note that I do not have a controller and use native iPeng.

Aesculus
2009-11-23, 17:56
Time to call off the dogs. It turns out I was chasing an elusive ghost in what I was trying to achieve. Pippin (iPeng author) had manually moved the Other Players plugin from extras into the player settings menu and I was unware of that. This is why my plugin did not show up. He informed me that I should call:

Slim::Control::Jive::registerPluginMenu(\@menu, 'settingsPlayer');

instead and sure enough this works like a champ.

pippin
2009-11-23, 18:03
Time to call off the dogs. It turns out I was chasing an elusive ghost in what I was trying to achieve. Pippen (iPeng author) had manually moved the Other Players plugin from extras into the player settings menu and I was unware of that. This is why my plugin did not show up. He informed me that I should call:

Slim::Control::Jive::registerPluginMenu(\@menu, 'settingsPlayer');

instead and sure enough this works like a champ.

sorry :(
Mea culpa...
As discussed offline: 'settingsPlayer' has the disadvantage that it will _only_ show in iPeng (or you have to add that menu manually on the Controller) in 7.4 or 7.5
A good alternative is "settingsAudio" then it will show up as a "Audio Settings" submenu.

Just in case somebody else is wondering....

Looks like I have to write up some docs as well...

Aesculus
2009-11-23, 19:12
Erland: Thanks for all the help here.

I do have one more small related question. Do you have an idea of how I can only load the menus for players that have enabled my plugin?

Today I have a means to only create callbacks for the players that have enabled the plugin but in the case of the main Jive menu it seems to be active for all players.

Of course I can limit the submenus from being called, but I was wondering how I could only load the main menu for thoese players specific to my plugin.

I have access to:



my $cprefs = $prefs->client($client);
my $pluginEnabled = $cprefs->get('pref_Enabled');

to figure out if a player is enabled.

erland
2009-11-24, 10:00
I do have one more small related question. Do you have an idea of how I can only load the menus for players that have enabled my plugin?

Today I have a means to only create callbacks for the players that have enabled the plugin but in the case of the main Jive menu it seems to be active for all players.

Of course I can limit the submenus from being called, but I was wondering how I could only load the main menu for thoese players specific to my plugin.

By looking at the code, it looks like registerPluginMenu can take a third $client parameter.

Why don't you try to call registerPluginMenu like this instead and see if it works:


Slim::Control::Jive::registerPluginMenu(\@menu, 'extras',$client);

It probably means that you will need to call registerPluginMenu when the player connects instead of doing it in initPlugin, the reason is that I don't think the players are connected when initPlugin is called (but I might be wrong about this).

You should be able to use Slim::Control::Request::subscribe to subscribe on player connect/disconnect and make the registerPluginMenu call there instead. I think you might be able to find some sample code in the ABTester plugin, it subscribes on reconnect event with this code:


Slim::Control::Request::subscribe(\&loadDefaultDSPImage,[['client','reconnect']]);

You will find the ABTester plugin here:
http://svn.slimdevices.com/repos/slim/7.4/trunk/contrib/plugins/ABTester/lib/Plugins/ABTester/Plugin.pm

Aesculus
2009-11-24, 10:23
Erland: I will give your idea of the $client parameter a try.

I already do the subscribe feature today when setting up my players (I have a newPlayers subscribe action) so its a natural.

I have just recently moved my main items over to a list vs a menu as a subset of Players Audio to remove a layer, but I think I can work this out.

This may take me a day or so. I will post back then on success/failure.

Aesculus
2009-11-24, 10:56
Erland: I was able to make this change with just two lines of code.

Unfortunately it did not work so I will start a new thread on this subject.