-
Notifications
You must be signed in to change notification settings - Fork 10
/
videoloop.sh
executable file
·57 lines (47 loc) · 938 Bytes
/
videoloop.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
53
54
55
#!/bin/bash
if pgrep omxplayer; then
echo "Stopping"
pkill omxplayer
pkill videoloop
exit;
fi
# Variables
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
MEDIA_PATH=/media/usb
AUDIO_OUTPUT=hdmi # hdmi or local
# External config
if [ -f $MEDIA_PATH/config.txt ]; then
source $MEDIA_PATH/config.txt
fi
# Variables
MEDIA_PATH=/media/usb
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
# Hide terminal
setterm -cursor off
setterm -foreground black
setterm -clear
onExit()
{
setterm -cursor on
setterm -foreground white -clear
IFS=$SAVEIFS
exit $?
}
# trap keyboard interrupt (control-c)
trap onExit SIGINT
# infinite loop
while true; do
if pgrep omxplayer; then
pkill omxplayer
sleep 1;
else
# For each video
for f in `ls $MEDIA_PATH | grep ".mp4$\|.avi$\|.mkv$\|.mp3$\|.mov$\|.mpg$\|.flv$\|.m4v$\|.divx$"`; do
omxplayer -b --no-keys --no-osd -o $AUDIO_OUTPUT "$MEDIA_PATH/$f"
done
fi
done
# Things to do on exit
onExit