PDA

View Full Version : Radio buttons in OPML ?



erland
2008-07-02, 01:13
When looking at the code in Buttons::XMLBrowser there seems to be some code that indicates that it should be possible to represent radio buttons in an OPML structure.

Does anyone know how this works ?
Is it supposed to work in all interface or just the player interface ?

I've got it to show the menu by having OPML entries like those generated from this code:


my @ratingValues = ();
for my $value (qw(0 20 40 60 80 100)) {
my $ratingValue = {
'type' => 'radio',
'default' => 40/100',
'name' => $value.'/100',
};
push @ratingValues,$ratingValue;
}
my $item = {
type => 'opml',
name => cstring($client, 'RATING') . cstring($client, 'COLON') . ' ' . $rating.'/100',
items => \@ratingValues,
};


The result is that it displays a menu with radio buttons in the player interface, but I just get some cryptical error when hitting right on one of the radio button menu items.

I would like to be able to execute some code when the user selects and hit right on a radio button menu item.

The reason for all this is that I try to provide a menu item where the user can change the track rating through the new Menu::TrackInfo handling.

mherger
2008-07-02, 01:52
> The result is that it displays a menu with radio buttons in the player
> interface, but I just get some cryptical error when hitting right on
> one of the radio button menu items.

While I have no idea bout all this, I just wanted to tell you that error messages can be very helpful when trying to understand what's going wrong :-). Mind sharing it with us?

--

Michael

erland
2008-07-02, 04:56
While I have no idea bout all this, I just wanted to tell you that error messages can be very helpful when trying to understand what's going wrong :-). Mind sharing it with us?


This is the error:


[08-07-02 13:42:17.0637] Slim::Utils::Misc::msg (1350) Warning: [13:42:17.0632] Use of uninitialized value in concatenation (.) or string at /usr/src/slimserver71/server/Slim/Networking/SimpleAsyncHTTP.pm line 105.
[08-07-02 13:42:17.0653] Slim::Control::Request::execute (1789) Error: While trying to run function coderef [Slim::Control::Commands::buttonCommand]: [Assert_Defined failed: Cache::BaseCache line 194]


The problem is that I need to somehow specify which code that should be executed when the radio button is selected, however I've no idea how to do that.

I can add an 'url' element and then the XMLBrowser will retrieve that and interpret the response as OPML. I suppose I can implement my own page handler that executes some code and returns some OPML result, but I have a feeling there has to be an easier way to just select a radio button in a OPML menu.

andyg
2008-07-02, 05:36
Yeah, radio buttons are supported but in the player UI only. I added this for the Pandora station sort order menu.

You need a url item that saves the selected radio item. In Pandora this is implemented in real OPML and looks like this:



<outline text="Station Sort Order">
<outline URL="http://www.squeezenetwork.com/api/pandora/v1/opml/setSort?field=alphabetical&order=asc" default="Sort oldest stations first" text="Sort alphabetically" type="radio"/>
<outline URL="http://www.squeezenetwork.com/api/pandora/v1/opml/setSort?field=dateCreated&order=desc" text="Sort newest stations first" type="radio"/>
<outline URL="http://www.squeezenetwork.com/api/pandora/v1/opml/setSort?field=dateCreated&order=asc" text="Sort oldest stations first" type="radio"/>
</outline>


Try setting a coderef for the url field for each radio item.

erland
2008-07-02, 07:00
Try setting a coderef for the url field for each radio item.

coderef's doesn't seem to work in the url field when used from the track info menu. When I have a coderef in the url I just get:


[08-07-02 15:58:53.4352] Slim::Control::Request::execute (1789) Error: While trying to run function coderef [Slim::Control::Commands::buttonCommand]: [Can't call method "can" on unblessed reference at /usr/src/slimserver71/server/CPAN/HTTP/Request.pm line 72.]

andyg
2008-07-02, 07:15
Some of the other track info items use the coderef method, check those for a working example.

erland
2008-07-02, 08:09
Some of the other track info items use the coderef method, check those for a working example.

It works fine if type is 'opml' but not if type is 'radio'.

I suppose I can make my own indication of the currently selected item instead of the standard 'radio' buttons.

andyg
2008-07-02, 08:17
On Jul 2, 2008, at 11:09 AM, erland wrote:

>
> andyg;316634 Wrote:
>> Some of the other track info items use the coderef method, check
>> those
>> for a working example.
>
> It works fine if type is 'opml' but not if type is 'radio'.
>
> I suppose I can make my own indication of the currently selected item
> instead of the standard 'radio' buttons.

When I implemented ratings in Rhapsody I just made a simple menu like
this:

Rating: ***** ->
None
*****
****
***
**
*

I'm not sure it requires radio buttons at all.

erland
2008-07-02, 09:24
When I implemented ratings in Rhapsody I just made a simple menu like
this:

Rating: ***** ->
None
*****
****
***
**
*

I'm not sure it requires radio buttons at all.

That should work.
Is there a way I can refresh the parent menu after I've changed the rating ?

At the moment it seems like I have to step back to the track title and step in again to refresh the rating item.

andyg
2008-07-02, 09:37
On Jul 2, 2008, at 12:24 PM, erland wrote:

>
> andyg;316659 Wrote:
>> When I implemented ratings in Rhapsody I just made a simple menu like
>> this:
>>
>> Rating: ***** ->
>> None
>> *****
>> ****
>> ***
>> **
>> *
>>
>> I'm not sure it requires radio buttons at all.
>
> That should work.
> Is there a way I can refresh the parent menu after I've changed the
> rating ?
>
> At the moment it seems like I have to step back to the track title and
> step in again to refresh the rating item.

Try adding refresh => 1. See Favorites for an example.

erland
2008-07-02, 11:08
On Jul 2, 2008, at 12:24 PM, erland wrote:
> Is there a way I can refresh the parent menu after I've changed the
> rating ?
>
> At the moment it seems like I have to step back to the track title and
> step in again to refresh the rating item.[/color]

Try adding refresh => 1. See Favorites for an example.

Ok, it doesn't work for items inside the "moreinfo" group, but it does work for top level item. So if I move the 'rating' item to the top everything works correctly, but if I move it into the "moreinfo" group it doesn't.

Could it be caused by the fact that XMLBrowser search for onRefresh two mode levels up at line 500 in Slim/Buttons/XMLBrowser.pm ?

It works if I have popback => 3 instead of popback => 2 in my OPML structure, but that will of course be a bit confusing for the end user.

erland
2008-07-02, 11:20
Is there some way I can force the position to a specific item when browsing into a sub menu in the TrackInfo menu ?

The player remembers the last position, but for the rating sub menu I would like it to be placed at the current rating instead of the last position.

andyg
2008-07-02, 11:48
On Jul 2, 2008, at 2:20 PM, erland wrote:

>
> Is there some way I can force the position to a specific item when
> browsing into a sub menu in the TrackInfo menu ?
>
> The player remembers the last position, but for the rating sub menu I
> would like it to be placed at the current rating instead of the last
> position.

No. You can either have it remember or always go to the first item by
setting remember => 0. Keep in mind that's only for the player UI.