-
Notifications
You must be signed in to change notification settings - Fork 36
/
startvideos.sh
executable file
·52 lines (43 loc) · 1.08 KB
/
startvideos.sh
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
declare -A vids
#Make a newline a delimiter instead of a space
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
configs=`cat /boot/looperconfig.txt`
usb=`echo "$configs" | grep usb | cut -c 5- | tr -d '\r' | tr -d '\n'`
audio_source=`echo "$configs" | grep audio_source | cut -c 14- | tr -d '\r' | tr -d '\n'`
seamless=`echo "$configs" | grep seamless | cut -c 10- | tr -d '\r' | tr -d '\n'`
FILES=/home/pi/videos/
if [[ $usb -eq 1 ]]; then
FILES=/media/USB/videos/
fi
if [ -n "$seamless" ] && [[ ! "$seamless" -eq 0 ]]; then
#run the seamless looper
echo "seamless isn't 0"
`/opt/vc/src/hello_pi/hello_video/hello_video.bin "$FILES$seamless"`
exit 0
fi
current=0
for f in `ls $FILES | grep ".mp4$\|.avi$\|.mkv$\|.mp3$\|.mov$\|.mpg$\|.flv$\|.m4v$"`
do
vids[$current]="$f"
let current+=1
echo "$f"
done
max=$current
current=0
#Reset the IFS
IFS=$SAVEIFS
while true; do
if pgrep omxplayer > /dev/null
then
echo 'running'
else
/usr/bin/omxplayer -r -o "$audio_source" "$FILES${vids[$current]}"
let current+=1
if [ $current -ge $max ]
then
current=0
fi
fi
done