On Wed, 23 Mar 2016 16:11:45 +0100 Mehturt <meht...@gmail.com> wrote:
> I've created last.fm scrobbler using their 2.0 API, since the current > one was not working properly. > It's a Perl script that parses "xmms2 current" output and acts upon it. > I am currently testing it by running it in a loop, like this: > > while [ true ]; do > xmms2 current | ./script.pl > sleep 30 > done > > but I thought there would be a better way to get notified by xmms2 > e.g. when track changes. If you want to use perl, there definitely is, since we have perl client bindings :). I'd start by looking at https://git.xmms2.org/xmms2/xmms2-tutorial/tree/perl/tut6.pl. After applying the attached patch, it'll print the ID of the current song whenever the track changes. $ perl tut6.pl Current id is 47 Current id is 499 Current id is 650 Current id is 900 Current id is 733 Current id is 783 Current id is 108 Current id is 894 Current id is 717 Current id is 395 ^C The code for the perl bindings, to see what is available, is at https://git.xmms2.org/xmms2/xmms2-devel/tree/src/clients/lib/perl. > I'm aware of xmms2 MPRIS bridge and I'm using it to update my jabber > status via libpurple, is there anything else like this available? > Something lightweight and simple. Insert a hipstercat meme here. XMMS2 has had a client-server architecture with client bindings since 2003 :). > Thanks for any ideas. Feel free to ask for help if you need it. We're also in #xmms2 on Freenode. Cheers, Erik / nesciens
>From a1806627ee9f65ee2d0f23775d70cc1ad7be0fe1 Mon Sep 17 00:00:00 2001 From: Erik Massop <emas...@google.com> Date: Wed, 23 Mar 2016 22:14:25 +0000 Subject: [PATCH] Demonstrate broadcasts by changing perl/tut6.pl --- perl/tut6.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/perl/tut6.pl b/perl/tut6.pl index a569c24..28afb6c 100644 --- a/perl/tut6.pl +++ b/perl/tut6.pl @@ -25,7 +25,7 @@ sub my_current_id { # which was passed in as the userdata. printf "Current id is %d\n", $value; - $xc->quit_loop; + return 1 } # Let's ask for the current id in an async way instead of the sync way as we @@ -36,7 +36,8 @@ sub my_current_id { # $request->notifier_set( \&my_current_id, $xmms ); #$xmms->request( playback_current_id => \&my_current_id ); -$xmms->request( playback_current_id => sub { my_current_id (@_, $xmms) } ); +$xmms->request( broadcast_playback_current_id + => sub { my_current_id (@_, $xmms) } ); # As you see we do it pretty much the same way that we did in tut2, but instead # of being able to access the current id directly (as we would have if we where -- 2.1.4
-- _______________________________________________ Xmms2-devel mailing list Xmms2-devel@lists.xmms2.org https://lists.xmms2.org/cgi-bin/mailman/listinfo/xmms2-devel