In order to play media files inside a directory with mplayer, I have written a shell script. Please save it in a directory in your $PATH variable.
For example, ~/bin/mplayer_dir.sh
#!/bin/bash
# Plays files inside a directory with mplayer
playlist="/home/mitesh/.mplayer/playlist.txt"
dir="./"
if [[ $# > 0 ]]
then
dir=$1
fi
#rm -f $playlist
find "$dir" -iname "*" | egrep -i "\.(wma|wmv|flv|mp3|avi|vob|dat|mp4|m4v|ogg|divx|xvid|rmvb|rm|asf)$" | sort > $playlist
#cat $playlist
nlines=`wc -l $playlist | awk '{print $1}'`
if [[ $nlines > 0 ]]
then
mplayer -playlist $playlist
else
echo "$0: Unrecognized files in $dir"
echo "Please update this script if playable format is present."
fi
--------------
Sample Run:
$ mplayer_dir.sh [directory]