Friday, October 23, 2009

Gapless Playback and Scrobbling With mplayer

Gapless Playback + Scrobbling = <3

So, I listen to music a lot. And I listen to a lot of music. A couple of my favorite artists track for gapless playback (two albums I'm queuing up right now include Colors by Between the Buried and Me and The Incident by Porcupine Tree). I got fed up trying to find a media player for Linux (I have CentOS at work) that doesn't suck majorly at everything, and I really would like to scrobble what I listen to.


If you read my blog (haha), you'll have noticed a previous post about mplayer. I went out and googled, and came up with the following.


You'll want to get http://www.update.uu.se/~zrajm/programs/mplayer-lastfm/mplayer-lastfm-0.2.2 (if it disappears, send me an email). This is a perl script that parses mplayer output and scrobbles it to last.fm. It requires Digest::MD5 and LWP::UserAgent. In addition to obviously needing mplayer, you'll also need taginfo from http://grecni.com/software/taginfo/taginfo-1.2.tar.bz2 (which in turn needs taglib).


After this, create an .mplayer-lastfmrc file containing the lines:


user = [your username]

pass = [your password]

Once you've done this, follow these helpful steps (from http://snipplr.com/view/18353/gapless-playback-for-mplayer-linux/):


mkfifo aufifo

aplay -t raw -c 2 -f S16_LE -r 44100 aufifo &> /tmp/aplayfifo.log &

After that, simply run:


./mplayer-lastfm-0.2.2 -ao pcm:nowaveheader:file=aufifo path/to/*.mp3


Once mplayer-lastfm quits, though, you'll have to re-create your fifo. Perhaps I'll make a script for that. :)


Enjoy!


--dho

0 comments: