Author | Message | Time |
---|---|---|
JoeTheOdd | A few things 1) This is my very first time ever using perl. When run in a terminal, it will output an error (about the way I call main()). If someone would like to fix this (or provide a link to information about this problem), it'd be apreciated. When run with JavaOp's /run command (which is why I made this), it doesn't output the error. Hm. 2) This will either output "XMMS Not Running" or the current MP3 using echo. In JavaOp, this is outputted to the chat window (in blue, ooh). 3) This is much easier to use if you move it to /usr/bin, asuming you have root access. 4) This code was written by Newby as an X-Chat perl script for the exact same purpose. All I did was basically stab it repetedly until it printed to the screen (it was rather easy too). Without further ado, I present to you.. [code]#!/usr/bin/perl -w # http://www.x86labs.org/ # http://www.javaop.com/~joe/ # Special thanks to Newby[x86]! use Xmms::Remote (); my $xmms = Xmms::Remote->new; main(); sub main() { if (! $xmms->is_running) { system("echo 'XMMS Not Loaded'"); }else{ my $song = (($xmms->get_playlist_pos()) + 1); my $song2 = $xmms->get_playlist_title(); my $songpos = parse_time($xmms->get_output_time); my $songlen = parse_time($xmms->get_playlist_time); my @songinfo = $xmms->get_info(); my $prefix = "Current MP3:"; my $message = "$prefix $song2 [$songpos of $songlen] [".($songinfo[0]/1000)."kbps]"; system("echo $message"); } } sub parse_time() { my $xmms_time = shift; my $seconds = $xmms_time / 1000; my $minutes = $seconds / 60; $seconds = $seconds % 60; return sprintf("%02d:%02d", $minutes, $seconds); }[/code] | November 5, 2005, 1:44 AM |
Kp | No need to use echo, just print it directly. I can't debug your other problem though, since I don't have XMMS integration in Perl. [code]--- a/joe.pl 1970-01-01 00:00:00.000000000 -0000 +++ b/joe.pl 1970-01-01 00:00:00.000000000 -0000 @@ -11,7 +11,7 @@ sub main() { if (! $xmms->is_running) { - system("echo 'XMMS Not Loaded'"); + print "XMMS Not Loaded\n"; }else{ my $song = (($xmms->get_playlist_pos()) + 1); my $song2 = $xmms->get_playlist_title(); @@ -20,7 +20,7 @@ my @songinfo = $xmms->get_info(); my $prefix = "Current MP3:"; my $message = "$prefix $song2 [$songpos of $songlen] [".($songinfo[0]/1000)."kbps]"; - system("echo $message"); + print "$message\n"; } }[/code] | November 5, 2005, 2:28 AM |
JoeTheOdd | The other thing is a perl problem, not an XMMS problem. This post and the one below it should have XMMS Remote up and running in less than 5 minutes, if you want it. Also, thanks. =) | November 5, 2005, 2:56 AM |
Newby | I see. People respond to his, but when it comes down to my original post and coding, it goes ignored. At this point, why do you even bother having the $prefix variable if you aren't going to use my prefix-retrieval sub? Also, the $song variable goes un-used. You really didn't do a very good job of slicing up my source, did you? | November 5, 2005, 6:53 PM |
JoeTheOdd | [quote]<TehUser> Shut up, newby, you're here too often to know anything about women.[/quote] <3. Anyhow, it works for my cause, so eh? And I used prefix because I'm too lazy to not do it (even though its obviously far too easy for even me to not know how). | November 5, 2005, 11:40 PM |