bin sh FILE tmp mp_info FIFO home kain mplayer-control TIME_FOLDER hom

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
FILE="/tmp/mp_info"
FIFO="/home/kain/.mplayer-control"
TIME_FOLDER="/home/kain/.mplayer/time"
mplayer="/home/kain/.bin/mp.sh"
case "$1" in
exit)
echo "get_time_pos">$FIFO
echo "get_file_name">$FIFO
#sleep 1
POS=$(cat $FILE | grep ANS_TIME_POSITION|awk -F= '{print $2}'| head -n1)
NAME=$(cat $FILE | grep ANS_FILENAME|awk -F= '{print $2}'|sed s/\'//g|head -n1)
echo $POS > ${TIME_FOLDER}/${NAME}
$mplayer stop
;;
*)
file_name=$(echo "$1"|awk -F / '{print $NF}')
found=$(ls $TIME_FOLDER|grep $file_name)
if [[ $found ]]; then
if [[ ! -s $found ]];then
$mplayer "$1"
fi
start_from=$(cat $TIME_FOLDER/$found)
$mplayer start_from "$1" "$start_from"
else
$mplayer "$1"
fi
;;
esac
exit 0