PDA

View Full Version : addChildren/addCategory for player



Danny Rego
2005-05-31, 06:59
I'm having a problem that I hope someone has the answer to. I am trying to
add a page under the PLAYER menu for my plugin. So I am doing this on
initPlugin()...

Slim::Web::Setup::addChildren('player','weblogger' ,2);
Slim::Web::Setup::addCategory('weblogger',&setupCategory);

....it doesn't show up at all, but if I change 'player' to 'server', the page
will show up perfectly under the server settings menu. Can someone point me
in the right direction? I'm getting desperate. (I can't seem to find any
external plugin that adds itself to the player menu...so I'm not even sure
if this is possible...it looks to be, but who knows?!)

What magic am I missing here!?

Danny Rego

(incase anyone needs to see what the setupCategory func returns...here it
is)

sub setupCategory {
my %setupCategory =(
'title' => string('PLUGIN_TITLE'),
'isClient' => 1,
'parent' => 'player',
# 'preEval' => sub {
# my ($client,$paramref,$pageref) = @_;
# return if (!defined($client));
# Slim::Buttons::Plugins::addSetupGroups();
# Slim::Web::Setup::playerChildren($client, $pageref);
# },
'GroupOrder' => ['Test1'],
'Groups' => {
'Test1' => {
'PrefOrder' => ['testpref']
}
}
,'Prefs' => {
'testpref' => {
'validate' => \&Slim::Web::Setup::validateNumber,
'validateArgs' => [0,undef,1000]
}
}
);

return (\%setupCategory);
}

mherger
2005-05-31, 07:14
Danny

> Slim::Web::Setup::addChildren('player','weblogger' ,2);
> Slim::Web::Setup::addCategory('weblogger',&setupCategory);

Have you tried creating the category before adding a child to it? What
does the console say (add -d_plugin at startup)?

It should return something like "category does not exist" if you try to do
what you are doing.

> ...it doesn't show up at all, but if I change 'player' to 'server', the

Which does not make sense for me... But try it anyway :-)

--

Michael

-----------------------------------------------------------
Help translate SlimServer by using the
SlimString Translation Helper (http://www.herger.net/slim/)

Danny Rego
2005-05-31, 07:25
> Slim::Web::Setup::addChildren('player','weblogger' ,2);
> Slim::Web::Setup::addCategory('weblogger',&setupCategory);

>Have you tried creating the category before adding a child to it?

Yes...I actually had it that way at first.

>What does the console say (add -d_plugin at startup)?

Absolutely nothing!

>It should return something like "category does not exist" if you try to do
what you are doing.

> ...it doesn't show up at all, but if I change 'player' to 'server', the

>Which does not make sense for me... But try it anyway :-)

.....this is why I'm so frustrated on this one. It works under SERVER, ut I
can't get 'er to go under the PLAYER menu. (grr!)

Danny Rego

kdf
2005-05-31, 07:29
Quoting Danny Rego <danny (AT) rego (DOT) com>:


> What magic am I missing here!?
>

Offhand, I'd say its the subroutine, playerChildren in Setup.pm that is causing
you the trouble. That is the routine that sets up the appropriate player menus
depending on whether the player is http type or softsqueeze/hardware. This
would interfere with any attempt to create custom player tabs. You can create
a section under the player plugins tab if you add isClient => 1 to the
setupGroup (AlarmPlugin and MusicInfoSCR have examples)

When adding the addCategory feature, I didn't dig into adding player pages
because I wasn't sure it was such a good plan, given the potential for
instability due to the variety of player models that get connected. Calling
methods on clients can take down the server if they aren't properly handled.

It is probably only a matter of a quick sanity check in that routine to add the
custom tabs, or possibly to ensure that the routine is called BEFORE any custom
tabs are created.

-kdf

Robert Moser
2005-05-31, 07:37
Danny Rego wrote:
> I'm having a problem that I hope someone has the answer to. I am trying
> to add a page under the PLAYER menu for my plugin. So I am doing this
> on initPlugin()...
>
> Slim::Web::Setup::addChildren('player','weblogger' ,2);
> Slim::Web::Setup::addCategory('weblogger',&setupCategory);
>
> What magic am I missing here!?

The problem lies in the player category preEval. It calls
playerChildren() which then sets the children attribute to a hard-coded
list. There will need to be some tweaking done before it will be
possible to add children to the player category. The page itself is
probably being added though. You can see by replacing the "page=player"
in the URL with "page=weblogger".

I'm not entirely certain what the best way to move forward will be. For
now your best bet would be to use 'player_plugins' as your parent.

Robert Moser
2005-05-31, 07:43
kdf wrote:
> You can create
> a section under the player plugins tab if you add isClient => 1 to the
> setupGroup (AlarmPlugin and MusicInfoSCR have examples)

I missed this bit when I wrote my reply. Make sure that the third
return value (after your groupRef and prefRef) from your setupGroup() is
1 (that is where $isClient used in
Slim::Buttons::Plugins::addSetupGroups comes from).

mherger
2005-05-31, 07:54
> I missed this bit when I wrote my reply. Make sure that the third
> return value (after your groupRef and prefRef) from your setupGroup() is
> 1 (that is where $isClient used in
> Slim::Buttons::Plugins::addSetupGroups comes from).

The problem is that Danny does not want to add his preferences to the
plugin page - and you would not want this, neither. His prefs page is
_huge_ :-).

> possible to add children to the player category. The page itself is
> probably being added though. You can see by replacing the "page=player"
> in the URL with "page=weblogger".

If this is true here's my proposition for danny: add a small set of
prefs/settings to the plugins section together with a link to that page
with the advanced prefs.

Stuff like manual update, enable/disable automatic update etc. might be
useful if available with few clicks. But the upload method won't be
changed that often. In fact everything you've already integrated in the
player interface might be a good choice for the quick access plugins
settings page.

--

Michael

-----------------------------------------------------------
Help translate SlimServer by using the
SlimString Translation Helper (http://www.herger.net/slim/)

Danny Rego
2005-05-31, 08:18
Thanks for the info everyone...I guess I'll have to hack it in there. The
hard-coded children array looks to be where the woe is coming from here, so
I'll have to hack around to get my stuff in there for now.

Danny Rego



----- Original Message -----
From: "Robert Moser" <rlmoser (AT) comcast (DOT) net>
To: "Slim Devices Developers" <developers (AT) lists (DOT) slimdevices.com>
Sent: Tuesday, May 31, 2005 10:43 AM
Subject: Re: [Developers] addChildren/addCategory for player


> kdf wrote:
>> You can create
>> a section under the player plugins tab if you add isClient => 1 to the
>> setupGroup (AlarmPlugin and MusicInfoSCR have examples)
>
> I missed this bit when I wrote my reply. Make sure that the third return
> value (after your groupRef and prefRef) from your setupGroup() is 1 (that
> is where $isClient used in Slim::Buttons::Plugins::addSetupGroups comes
> from).
>
>