#! /bin/bash
function play_video()
{
touch temp.sh
cat /dev/null > temp.sh
echo "vlc $1" > temp.sh
chmod +x temp.sh
./temp.sh&
sleep 10
#kill -9 `ps -e|grep vlc|awk '{print $1}'`
kill -9 `pgrep vlc`
sleep 1
}
function judge_file()
{
temp=$1
last=${temp##*.}
if [ $last = "mov" ] || [ $last = "ts" ]
then return 1
else return 0
fi
}
function read_dir(){
for file in `ls $1`
do
if [ -d $1"/"$file ]
then
read_dir $1"/"$file
else
judge_file $file
if [ $? = 1 ]
then
play_video $1"/"$file
fi
fi
done
}
#测试目录 test
read_dir /home/tarena/Desktop/video/