PDA

View Full Version : Question on callback function after playlist: Stillconfused



Tom Weilenmann
2003-11-13, 00:44
Hello again

Here is what I'm trying to do:
After a break of a few months I have decided to continue the work on my answer machine plugin. The plugin will be the frontend for the answer machine software which I'm allready running on my server.

The Plugin will/should be able to hande several different directories for messages. New for new messages, Old for messages which have allready been played at least once (New messages should move to Old after the first playback), Trash for deleted messages and finaly Keep for messages you want to keep for some reason. This whole directory stuff is defined by a configuration file, which means that one coud also think of a different directory structure. The whole config stuff is allready working fine.

Beside of just playing the message files in a specific folder, the plugin must react to commands from the remote and it has to move files from one folder to another (automatic move to Old when a message in the New folder has been played or move to some specific folder when a button on the remote is pressed). To be able to trigger the move file/message command at the right moment (after the end of playback) with the right parameters I need to know when the playback of the message ends (otherwise I would pobably move a wrong file or the file cant be moved since it is still in use by the server software).

Any hints?

Thanks

Tom

Kevin Deane-Freeman
2003-11-13, 01:13
one thing you can do to take a look at your options:
start with creating a command callback using:
SliMP3::Command::setExecuteCallback(\&commandCallback);

then create a subroutine for commandCallback like so:
sub commandCallback {
my $client = shift;
my $paramsRef = shift;
my $slimp3Command = @$paramsRef[0];
my $paramOne = @$paramsRef[1];
if ($::d_stdio) {
print "----------------------------\n";
print "| COMMAND: $slimp3Command\n";
foreach my $i (@$paramsRef[1..scalar(@$paramsRef)-1]) {
print "| PARAMS: $i\n";
}
print "----------------------------\n";
}
the commands you can react to will be contained in $slimp3Command with the rest
of $paramsref containing the command paramaters. Using "Open" was a trick first
suggested in Felix's announcement script. I haven't personally found any better
way to detect when a song is changing (or rather, in this case, about to
change). If you have the time to watch the output from the above routine, you
may find something more to your liking. btw, have to turn on --d_stdio to get
the printouts :)

cheers,
kdf



Quoting Tom Weilenmann <Tom (AT) weilenmann (DOT) net>:

> Hello again
>
> Here is what I'm trying to do:
> After a break of a few months I have decided to continue the work on my
> answer machine plugin. The plugin will be the frontend for the answer machine
> software which I'm allready running on my server.
>
> The Plugin will/should be able to hande several different directories for
> messages. New for new messages, Old for messages which have allready been
> played at least once (New messages should move to Old after the first
> playback), Trash for deleted messages and finaly Keep for messages you want
> to keep for some reason. This whole directory stuff is defined by a
> configuration file, which means that one coud also think of a different
> directory structure. The whole config stuff is allready working fine.
>
> Beside of just playing the message files in a specific folder, the plugin
> must react to commands from the remote and it has to move files from one
> folder to another (automatic move to Old when a message in the New folder has
> been played or move to some specific folder when a button on the remote is
> pressed). To be able to trigger the move file/message command at the right
> moment (after the end of playback) with the right parameters I need to know
> when the playback of the message ends (otherwise I would pobably move a wrong
> file or the file cant be moved since it is still in use by the server
> software).
>
> Any hints?
>
> Thanks
>
> Tom
>
>
>

dean
2003-11-13, 09:31
This is a good suggestion.

Add to this a patch from "Playlist::openNext" to call
"Command::execute" with an event for notifying when a new song is
started and you should be good to go.


On Nov 13, 2003, at 12:13 AM, Kevin Deane-Freeman wrote:

> one thing you can do to take a look at your options:
> start with creating a command callback using:
> SliMP3::Command::setExecuteCallback(\&commandCallback);
>
> then create a subroutine for commandCallback like so:
> sub commandCallback {
> my $client = shift;
> my $paramsRef = shift;
> my $slimp3Command = @$paramsRef[0];
> my $paramOne = @$paramsRef[1];
> if ($::d_stdio) {
> print "----------------------------\n";
> print "| COMMAND: $slimp3Command\n";
> foreach my $i (@$paramsRef[1..scalar(@$paramsRef)-1]) {
> print "| PARAMS: $i\n";
> }
> print "----------------------------\n";
> }
> the commands you can react to will be contained in $slimp3Command with
> the rest
> of $paramsref containing the command paramaters. Using "Open" was a
> trick first
> suggested in Felix's announcement script. I haven't personally found
> any better
> way to detect when a song is changing (or rather, in this case, about
> to
> change). If you have the time to watch the output from the above
> routine, you
> may find something more to your liking. btw, have to turn on --d_stdio
> to get
> the printouts :)
>
> cheers,
> kdf
>
>
>
> Quoting Tom Weilenmann <Tom (AT) weilenmann (DOT) net>:
>
>> Hello again
>>
>> Here is what I'm trying to do:
>> After a break of a few months I have decided to continue the work on
>> my
>> answer machine plugin. The plugin will be the frontend for the answer
>> machine
>> software which I'm allready running on my server.
>>
>> The Plugin will/should be able to hande several different directories
>> for
>> messages. New for new messages, Old for messages which have allready
>> been
>> played at least once (New messages should move to Old after the first
>> playback), Trash for deleted messages and finaly Keep for messages
>> you want
>> to keep for some reason. This whole directory stuff is defined by a
>> configuration file, which means that one coud also think of a
>> different
>> directory structure. The whole config stuff is allready working fine.
>>
>> Beside of just playing the message files in a specific folder, the
>> plugin
>> must react to commands from the remote and it has to move files from
>> one
>> folder to another (automatic move to Old when a message in the New
>> folder has
>> been played or move to some specific folder when a button on the
>> remote is
>> pressed). To be able to trigger the move file/message command at the
>> right
>> moment (after the end of playback) with the right parameters I need
>> to know
>> when the playback of the message ends (otherwise I would pobably move
>> a wrong
>> file or the file cant be moved since it is still in use by the server
>> software).
>>
>> Any hints?
>>
>> Thanks
>>
>> Tom
>>
>>
>>
>