Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

cwest (1514)

cwest
  (email not shown publicly)
http://caseywest.com/
AOL IM: caseyrwest (Add Buddy, Send Message)

Perl geek.

Journal of cwest (1514)

Tuesday February 03, 2004
03:23 AM

Mac::Glue Rocks

[ #17174 ]

Thanks to Simon and Chris, I've got the Mac::Glue bug. I used to use a program to post journal entries that had iTunes support built in. Now that I use emacs, I'm at a loss, right? Wrong. Here is my program for getting an HTML version of the current playing track, not unlike what the article outlined.

Use Mac::Glue;
use Mac::Apps::Launch qw[IsRunning];

our $ITUNES = Mac::Glue->new( 'itunes' );
sub iTunes () { $ITUNES }


print get_track() || '';

sub get_track {
iTunes or return;
return unless IsRunning(iTunes->{ID});


if ( iTunes->prop('player_state')->get eq 'playing' ) {
my $track = iTunes->prop('current_track');
my ($name, $artist, $album) = map $track->prop($_)->get,
qw[name artist album];
my $output = "<p><em>Now Playing: $name";
$output .= " &middot; $artist" if $artist;
$output .= " &middot; $album" if $album;
return $output .= "</em></p>\n";
}
return;
}

And here is my emacs keybinding.

(global-set-key (kbd "C-c m")
(lambda () (interactive)
(shell-command-on-region
(region-beginning) (region-end)
"current_track.pl"
(current-buffer) t)))

http://www.perl.com/pub/a/2004/01/23/macglue.html

Now Playing: Overjoyed · Jars of Clay · Much Afraid

Posted from caseywest.com, comment here.

New comment creation has been disabled on this discussion.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login
Loading... please wait.