9

I'm looking for a terminal music player. mpg321/mpg123 is quite what I need, but it can't play all my music directory (which contains child directories). cmus seems to be a bit of an overkill, as there are a lot of features I never use.

I just need a program, that I can give it my music directory and perhaps a --random flag, then it will play everything with random orders. Can someone point out what options I have?

7 Answers 7

10

You can easily wrap up a script using find and rl (package randomize-lines on debian).

Something along the lines of:

find "$1" -type f -name *.mp3 | rl | while read FILE; do mpg123 "$FILE"; done
7
  • ha! I like this one the best :D
    – phunehehe
    Oct 2, 2010 at 16:34
  • 5
    If you don't have rl, sort -R accomplishes the same thing Oct 3, 2010 at 9:32
  • 1
    @MrShunz I think it is find "$1" -type f -name *.mp3, typo?
    – phunehehe
    Oct 3, 2010 at 11:35
  • @phunehehe eheh yeah typed that from memory... Oct 3, 2010 at 12:19
  • @Michael Mrozek that's even better ... sort should be present by default in most distros... Oct 3, 2010 at 12:20
7

I use gst123 as a command line player. Point it at the parent directory and it will shuffle through it and the child directories with the -z flag. I run it like this.

 gst123 -z ~/Music
1
  • this is actually nice, I'll try it some time, maybe when it's in the gentoo portage tree
    – phunehehe
    Oct 2, 2010 at 16:36
5

There is moc - Music on console. It's simpler than mpd, but ships with embedded ncurses frontend. You can use ncurses TUI with mocp or talk to the server directly.

Of course it can't do all the nifty stuff mpd can do, like network streaming, different outputs simultaneosly, etc. But as a simple console player on local machine it's pretty usefull. It works without initial configuration, in contrast to mpd. The server starts automatically when mocp is called w/o parameters, or can be started manually.

start the server

mocp -S

tell the server to append (-a) a music folder to the playlist and to switch shuffle on (-o shuffle) and to start playing (-p)

mocp -o shuffle -p -a ~/mymusicfolder

I've 9.2 GB flac files and it only need 6 sec to load it from sata 1 hdd. from my sata 2 ssd it's instant. My output is alsa. (Didn't had to configure)

https://wiki.archlinux.org/index.php/Moc

4
  • Currently my mpd runs "unconfigured", just with built-in defaults and information detected on startup.
    – manatwork
    Oct 4, 2011 at 7:15
  • oh, weird. According to wiki.archlinux.org/index.php/Mpd the user has to setup the files/folders with proper permissions, point to them in the config file and setup the sound devices at least. Maybe its destribution dependent.
    – kulpae
    Oct 4, 2011 at 14:34
  • 1
    Tried it again from zero and now indeed not created the ~/.mpd stuff. However my current working conf was certainly not created by me, as the files not match my naming convention. The audio_output device left unconfigured until present days and mpd automatically detects it on startup. BTW, it's also Alsa. Well, accept my upvote with apologies.
    – manatwork
    Oct 4, 2011 at 15:09
  • Ah, thx for pointing out that audio output is autodetected, good to know ^^ Apology accepted with a comment vote up ;) We all are here to learn.
    – kulpae
    Oct 4, 2011 at 15:19
4

You might try MPD it consists of a server backend and a separate frontend (which may but needn't run on the same machine). There are several great command line clients for it (see http://mpd.wikia.com/wiki/Clients)

1

I just use mplayer. I generated a list of files from my music folders and mplayer can take that file as a playlist and play it in random order.

1

I've spent some time fiddling with diverse minimalistic music players and today find myself especially partial to the relatively recent xmms2, a descendant (somewhat) of the venerable xmms music player.

It is a robust client-server application, designed to run full-featured from the command line or from multiple graphical clients, play practically any music encoding available, manage music collections while taking up as little processor time as possible.

0
0

Through this shell, your music library will be played randomly, without repeating any songs until all have been played.

The history of songs played is recorded in the file *. Sh.his. This history is reset automatically if you added a song to the music library or have already heard all the songs of your library, generating a new random list ever. Whenever you want you can reset the history is deleting the file *. Sh.his.

#!/bin/bash

#-----------------------------------INFO----------------------------------------------------------

#Through this shell, your music library will be played randomly, without repeating any songs until all have been played. 
#The history of songs played is recorded in the file "*. Sh.his". 
#This history is reset automatically if you added a song to the music library or have already heard all the songs of your library, 
#generating a new random list ever. Whenever you want you can reset the history is deleting the file "*. Sh.his".

#Press "q" to skip song
#Press "p" to pause song and resume song

#------------------------------CONFIGURATION------------------------------------------------------

#mplayer package needed (For debian/Ubuntu/Mint: "$ apt-get install mplayer")

#Select your music library path (all recursive folders will be included in the .mp3 files search):
path="/media/Datos/Música/Music/"

#-------------------------------------------------------------------------------------------------

while true
do

cadena=$(find "$path" -iname '*.mp3')                                   #search media files
nmedia=$(echo "$cadena" | wc -l)

if [ -f "$0.his" ]                                          #file exist
then
    value=$(<"$0.his")                                      #read file

    if [[ ( $(echo "$value" | sed -n 1p) != $nmedia ) || ( $(echo "$value" | sed -n 2p) == 0 ) ]]   #reset file conditions
    then
        listrand=$(seq 1 $nmedia | shuf)
        index=$nmedia
    else                                                #no reset file conditions
        nmedia=$(echo "$value" | sed -n 1p)
        index=$(echo "$value" | sed -n 2p)
        listrand=$(echo "$value" | sed -n 3p)
        listrand=$(echo "$listrand" | sed s/" "/\\n/g)
    fi  

else                                                    #file not exist
    listrand=$(seq 1 $nmedia | shuf)
    index=$nmedia
fi

nrand=$(echo "$listrand" | sed -n "$index"p)                                #select random number
cadena=$(echo "$cadena" | sed -n "$nrand"p)                             #select song with random number
index=$((index-1))                                          #write file
echo $nmedia > "$0.his"
echo $index >> "$0.his"
echo $listrand >> "$0.his"
mplayer "$cadena"                                           #play media file

done
exit 0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .