Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 105 lines (90 sloc) 3.07 KB
#!/bin/bash
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2010-2016 daid kahl <daidxor@gmail.com>
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
# 0. You just DO WHAT THE FUCK YOU WANT TO.
#
#
# Name: mplall v 0.12
# Does: loops mplayer on media files
# Last updated: 21 Dec 2016 14:40:43
VERSION=0.13
#TODO: catch PID of find to put on a control_c trap
function Usage () {
cat <<-ENDOFMESSAGE
mplall version $VERSION
Recursively find and play media files starting from the present directory
Video is full-screened, audio is gapless.
Usage $0: [-R] [-D]
options:
-D : Play media on Desktop
-R : Generate Random playlist
ENDOFMESSAGE
exit 1
}
# Set appropriate mplayer or die
if ( which mplayer2 &>/dev/null );then
MPLAYER="mplayer2 --gapless-audio"
elif ( which mplayer &>/dev/null );then
MPLAYER="mplayer"
echo "gapless audio disabled, install mplayer2 to enable: http://www.mplayer2.org/"
else
printf "mplall requires mplayer or mplayer2, but it's not in your PATH or not installed.\n\t(see http://www.mplayerhq.hu or http://www.mplayer2.org/)\nAborting.\n" >&2; exit 1;
fi
#hacks
#MPLAYER="mplayer"
Rflag=""
Dflag=""
while getopts 'RD' OPTION
do
case $OPTION in
R) Rflag=1
RANDOMIZE="-R";;
D) Dflag=1
which xwininfo &>/dev/null || { printf "mplall requires xwininfo for Desktop mode but it's not in your PATH or not installed.\n\t(see http://xorg.freedesktop.org/ )\nAborting.\n" >&2; exit 1; }
DESKTOPID=$(xwininfo -name Desktop | grep Desktop | awk '{printf $4}')
WID="-wid $DESKTOPID"
;;
*) Usage ;;
esac
done
if [[ -z "$Rflag" && -z "$Dflag" ]];then
# gets last argument
FILENAME="${@: -1}"
echo "Playing: $FILENAME"
fi
PWD=$(pwd)
if [[ "$PWD" = "$HOME" && -z "$FILENAME" ]];then
read -p "Really recursively search all files for media in $HOME? (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
continue
else
exit
fi
fi
if [ "$Rflag" ];then
echo "mplall generating random playlist..."
fi
if [[ -z "$FILENAME" ]];then
PLAYLIST="--playlist <(find -L "$PWD" -type f | \
egrep -i '(\.avi|\.flac|\.flv|\.mkv|\.mp3|\.mp4|\.mpeg|\.mpg|\.ogg|\.ogv|\.vob|\.x|\.wav|\.wmv)' | \
sort $RANDOMIZE )"
else
PLAYLIST="$FILENAME"
fi
# TODO: What went wrong with the FILENAME version?
#$MPLAYER $WID -fs -loop 0 -zoom -playlist "$PLAYLIST"
#echo "$MPLAYER $WID --fs --loop 0 --zoom $PLAYLIST"
#"$MPLAYER $WID --fs --loop 0 --zoom $PLAYLIST"
$MPLAYER $WID -fs -loop 0 -zoom -playlist <(find -L "$PWD" -type f | egrep -i '(\.avi|\.flac|\.flv|\.mkv|\.mp3|\.mp4|\.m4a|\.mpeg|\.mpg|\.ogg|\.ogv|\.vob|\.wav|\.wmv)' | sort $RANDOMIZE )
#$MPLAYER -wid 0x1000003 -fs -loop 0 -zoom -playlist <(find -L "$PWD" -type f | egrep -i '(\.avi|\.flac|\.flv|\.mkv|\.mp3|\.mp4|\.mpeg|\.mpg|\.ogg|\.ogv|\.vob|\.wav|\.wmv)' | sort $* )