Skip to content

Instantly share code, notes, and snippets.

@hsali
Created November 15, 2016 18:18
Show Gist options
  • Save hsali/1ae2daaed99f153640f7996b69c108d3 to your computer and use it in GitHub Desktop.
Save hsali/1ae2daaed99f153640f7996b69c108d3 to your computer and use it in GitHub Desktop.
Play random audio files from command line. It is mplayer which will play music command line.
#!/bin/bash
if [ "$1" = "" ]; then
echo "no directory defined!"
exit
fi
if [ "$2" = "" ]; then
echo "no file extension defined!"
exit
fi
while [ 1 ]
do
FILE=$(cd ${1}; find * | grep ${2}$ | shuf -n 1)
path1="$1$FILE"
/usr/bin/mplayer "$path1"
done
@hsali
Copy link
Author

hsali commented Nov 15, 2016

if you don't this command installed in your system. then first install it. using this command.

 sudo apt-get install mplayer

see the manual or help using command.

man mplayer 

or

mplayer --help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment