Slash Boxes
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)

  (email not shown publicly)
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";

And here is my emacs keybinding.

(global-set-key (kbd "C-c m")
(lambda () (interactive)
(region-beginning) (region-end)
(current-buffer) t)))

Now Playing: Overjoyed · Jars of Clay · Much Afraid

Posted from, 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.
More | Login
Loading... please wait.