Hacking the playlist II

In a previous post, I was extolling the virtues of the moosic audio server, and mentioned that I wanted to create a nice on-screen display showing what's currently playing. As it turns out, it's much easier than I hoped, thanks to two useful Perl modules: Audio::Moosic and X::Osd.

So, without further ado, here's the Perl script. I call it moosic_osd.pl, but you can call it whatever you like.

#! /usr/bin/perl -w

use Audio::File;
use Audio::Moosic;
use X::Osd;

my $osd = X::Osd->new(3); # arg means 3 lines


my $moo = Audio::Moosic::Unix->new();

while (1)
    my $fspec = $moo->current;

    if (! $fspec)
        $artist = "John Lennon";
        $title = "Two minutes silence";
        $album = "";
        my $af = Audio::File->new($fspec);
        $artist = $af->tag->artist() || "";
        $title = $af->tag->title() || "";
        $album = $af->tag->album() || "";
    $osd->string(0, $title);
    $osd->string(1, $artist);
    $osd->string(2, $album);


So, copy and paste that somewhere, and run it as a background job:

perl ./moosic_osd.pl &

...and you'll get a nice little on-screen display.

Tags: , , , ,

No comments: