Command-line shuffle

Posted by Michael Giarlo on September 26, 2009

Being a nerd, I tend to like the command-line. When I'm working on my laptop at home, I tend to like listening to music. Before I discovered that mplayer had a really convenient shuffle idiom, I would invoke it thusly (to listen to all my Pavement tracks in shuffle mode):

export IFS=$'\n'
for track in $(find /mnt/upnp/MediaTomb/Audio/Artists/Pavement -name \*.mp3 | ~/bin/shuffle.py); do mplayer $track; done

And the wee shuffle script I whipped together looks like this:

#!/usr/bin/env python
# shuffle.py
 
import sys
import random
 
args = list(sys.stdin)
random.shuffle(args)
sys.stdout.writelines(args)

And here's the convenient shuffle idiom that renders my arg-shuffling script somewhat useless:

find /mnt/upnp/MediaTomb/Audio/Artists/Pavement -name \*.mp3 | mplayer -playlist - -shuffle -loop 0
Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. Cecile Menard Wed, 11 Nov 2009 12:16:20 UTC

    Hi, Thanks for the tip. I've been using the last command line and the shuffle is working. Minor problem is that the commands listed in the man pages of mplayer don't seem to work (e.g. command to go to next track or stop track). Any idea?
    Here's an example of the output I get

    find [directory] -name \*.mp3 | mplayer -playlist – -shuffle -loop 0
    Reading from stdin…
    MPlayer SVN-r29237-4.4.1 (C) 2000-2009 MPlayer Team
    mplayer: could not connect to socket
    mplayer: No such file or directory
    Failed to open LIRC support. You will not be able to use your remote control.

    Playing [file] etc..

  2. Michael Giarlo Thu, 12 Nov 2009 21:25:17 UTC

    @Cecile: I have the same issues. Not sure why keyboard commands don't work in that mode. Be interested if you figure it out, though. Thanks for stopping by.

Comments