How do I play files in random order using the mplayer command line player under Linux / Unix operating systems?
You can play most files such as MPEG/VOB, AVI, ASF/WMA/WMV, RM, QT/MOV/MP4, Ogg/OGM, MKV, VIVO, FLI, NuppelVideo, yuv4mpeg, FILM and RoQ files in random order using the following command syntax:
mplayer -shuffle -playlist YOUR-PLAY-LIST-HERE
How Do I Generate a Playlist?
mplayer can play files according to a playlist file type such as ASX, Winamp, SMIL, or one-file-per-line format. You can use the find command to generate a playlist for mplayer:
$ cd /path/to/music/dir
$ find -type f -iname \*.mp3 > playlist.txt
mplayer Shuffle Mode Command
Type the following command:
$ mplayer -shuffle -playlist playlist.txt
🐧 20 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Hey look! it’s the bottom of the barrel! I wondered when we would run out of linux commands.
Open a terminal and cd to the directory that has the music files you want to play. next type “mplayer *.*” press enter. Enjoy!!!!
Now, what if i want to skip to the next song? what is the shortcut?
no problem, press enter will bring me to the next song.
Thank you :D
You can also press > and
Great tips!! Thanks for this beautiful post
how do I enqueue another song while one is already playing?
If only I had found this post earlier…
Great post! Thanks!
Vivek:
I have been wondering how to do what you so wonderfully explained for many years!
Thanks for your help — and thanks for helping the whole Linux/Gnu community!
‘mplayer *’ will do. Perhaps *.* is a relic from dos times :)
relic, lol, I miss dos.. Found another one tho! mplayer */* for your whole collection, it will do all in this directory, and all in one directory down.. I’ve also used mplayer */*/* to play two folders down.. =]
I bet there’s a way to do this without making a playlist.
Seems to work with regular filelists, e.g. mplayer -shuffle * will play files in the current directory in a random order.
Thanks Anonymous, that works for me!
i am actually almost disturbed at the amount of people praising this advice.
its RIDICULOUS!
so, on the one hand you have this simple idea of composing a command for terminal, BUT then you HAVE TO THEN ADD THE WHOLE BLOODY PLAYL;IST THAT YOU HAVE ALREADY GOT IN YOUR PLAYER?
how impractical and long winded is that?
stupid idea. really dumb.
and to cut a long story short:
WHERE IS THE BLOODY RANDOM/SHUFFLE BUTTON? (like any sensible decently designed player has)
not our server at work, no GUI.. plus on top of that, each employee has their own music folder, so depending on who’s working, is who has control over the music server via SSH.. so no buttons, except the ones at the keyboard, and no mouse control.. period..
but it’s cool man, we let it slide for noobs around here; because, everyone “praising” this post, can tell that you’ve never used a terminal before.
This should work also.
mplayer -shuffle -loop 0 *.mp3
If I understand correctly the several comments in this post, it is not possible to remove the -shuffle when we are in slave mode?
By example, I have start mplayer in slave mode, I currently have script to “loadlist toto.m3u >/tmp/my.mplayerontroller” and I want to add the option to play my playlist with our without shuffle.
Will I have to kill mplayer and restart it to achieve this? or is there a slave mode command like “shuffle true >/tmp/my.mplayerontroller”
MPlayer shuffle is not random at all. I know good random generators are not trivial to make, but there are good, free solutions out there. This is really getting irritating. After using it for a while, I can predict which folder it will visit, which also means the mplayer RNG does not cover all the files.