PDA

View Full Version : Re: "Hello World" type plug-in...



fcm4711
2004-08-07, 01:55
Hi Danny

The best way to learn about plugins is looking at how
other plugins work. That how I do it.

A good way to hook into events is to install a
callback function when entering your plugin.

Slim::Control::Command::setExecuteCallback(
\&commandCallback);

Then in the callback function you need to filter to
the event you're interested. This example looks at
all ir commands from the remote.

sub commandCallback {
my $client = shift;
my $paramsRef = shift;
if( $paramsRef->[0] eq 'ir') {

<do whatever needed>

}
}

Have a look at Slim::Control::Command.pm and you
will see what events you can filter and what the
parameters are.

Then on leaving your plugin you should also remove
the callback function.

Slim::Control::Command::clearExecuteCallback(
\&commandCallback);

Hope that helps
Felix

--- Danny Rego <danny (AT) rego (DOT) com> wrote:

> Could someone point me in the right direction on
> this?! I want to get into programming plug-ins for
> my squeezebox, and I can pretty much see how things
> are interfaced between plug-in, and squeezebox...at
> least from what I can see so far, plug-ins, just
> need to be programmed to re-act to events (such as a
> button press on a remote).
>
> Is it possible at all to make a plug-in that simply
> logs the name of each song that is played, AS it's
> played? In other words, is there a way to "HOOK"
> into an "OnPlay" event, or something like that,
> where your function is only called when a new song
> is being played.
>
> I did some poking around, and the closest thing I
> found was a script that queries the Squeezebox every
> minute (from a PC), and logs the last song played to
> a file.
>
> (I hope this request made sense...it's 3:15am, and
> I'm fried right now...haahaa!)
>
> Danny Rego>

Danny Rego
2004-08-07, 15:56
Excellent!!! Thanks for the helpful info...it's exactly what I was looking
for to get started.

Danny Rego


----- Original Message -----
From: "Felix Mueller" <fcm4711 (AT) yahoo (DOT) com>
To: "Slim Devices Developers" <developers (AT) lists (DOT) slimdevices.com>
Sent: Saturday, August 07, 2004 4:55 AM
Subject: Re: [Developers] "Hello World" type plug-in...


> Hi Danny
>
> The best way to learn about plugins is looking at how
> other plugins work. That how I do it.
>
> A good way to hook into events is to install a
> callback function when entering your plugin.
>
> Slim::Control::Command::setExecuteCallback(
> \&commandCallback);
>
> Then in the callback function you need to filter to
> the event you're interested. This example looks at
> all ir commands from the remote.
>
> sub commandCallback {
> my $client = shift;
> my $paramsRef = shift;
> if( $paramsRef->[0] eq 'ir') {
>
> <do whatever needed>
>
> }
> }
>
> Have a look at Slim::Control::Command.pm and you
> will see what events you can filter and what the
> parameters are.
>
> Then on leaving your plugin you should also remove
> the callback function.
>
> Slim::Control::Command::clearExecuteCallback(
> \&commandCallback);
>
> Hope that helps
> Felix
>
> --- Danny Rego <danny (AT) rego (DOT) com> wrote:
>
> > Could someone point me in the right direction on
> > this?! I want to get into programming plug-ins for
> > my squeezebox, and I can pretty much see how things
> > are interfaced between plug-in, and squeezebox...at
> > least from what I can see so far, plug-ins, just
> > need to be programmed to re-act to events (such as a
> > button press on a remote).
> >
> > Is it possible at all to make a plug-in that simply
> > logs the name of each song that is played, AS it's
> > played? In other words, is there a way to "HOOK"
> > into an "OnPlay" event, or something like that,
> > where your function is only called when a new song
> > is being played.
> >
> > I did some poking around, and the closest thing I
> > found was a script that queries the Squeezebox every
> > minute (from a PC), and logs the last song played to
> > a file.
> >
> > (I hope this request made sense...it's 3:15am, and
> > I'm fried right now...haahaa!)
> >
> > Danny Rego>
>