<?sphp $this->text('pagetitle') ?>
 
Home of the Squeezebox™ & Transporter® network music players.

PluginFunctions

From SqueezeboxWiki

Jump to: navigation, search

Squeezebox Server handles all commands from the remote control for each mode by creating a hash table of functions, each button having a subroutine associated with it. The subroutine getFunctions() returns a reference to this hash, and can be any label you wish, although typically %functions is used. The call to point to this list is shown above in example 1. The function list, should look something like this example taken from rescan.pm, which is included with the Squeezebox Server:

Example 2:

our %functions = ();
sub initPlugin { 
    %functions = ( 
        'up' => sub { 
            my $client = shift; 
            $client->bumpUp(); 
        }, 
        'down' => sub { 
            my $client = shift; 
            $client->bumpDown(); 
        }, 
        'left' => sub { 
            my $client = shift; 
            Slim::Buttons::Common::popModeRight($client); 
        }, 
        'right' => sub { 
            my $client = shift; 
            $client->bumpRight(); 
        }, 
        'play' => sub { 
            my $client = shift; 
            my @pargs = 'rescan'; 
            my $line1 = $client->string('PLUGIN_RESCAN_MUSIC_LIBRARY'); 
            my $line2 = $client->string('PLUGIN_RESCAN_RESCANNING'); 
            Slim::Control::Request::executeRequest($client, \@pargs); 
            $client->showBriefly(, $line1, $line2); 
        } 
    ); 
}

Each remote button (eg. 'play') points to a subroutine to be performed each time that button is pressed. In the case above, pressing play sets up local variables, starts a rescan of the entire library, then shows two lines on the display for a short time to tell the user that the rescan has been started. The line "my $client = shift;" is very important here to keep track of the player status, and to pass on in server function calls such as:

$client->showBriefly(, $line1, $line2);

Examples of remote control functions include: 'up','down','play,'add' (REC button),'left','right','numberScroll' and 'stop' The full button to function map is found in the Default.map file, which is in the IR directory under the Squeezebox Server directory.

Next PageMedia:Voorbeeld.ogg