55 lines
1.3 KiB
Bash
Executable File
55 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
folderext="/media/video/video" ### var: path to videofiles on external device
|
|
folderint="/home/pi/birdcam/video" ### var: path to videofiles on sdcard storage
|
|
player="cvlc" ### var: player command
|
|
playerparam="--no-osd --play-and-exit" ### var: player parameters
|
|
|
|
player_path="$(command -v $player)"
|
|
|
|
player_package="vlc" ### var: player apt package
|
|
mountdevice="sda1" ### var: device for mediafiles
|
|
|
|
if [ -z "$player_path" ]; then
|
|
echo "Missing $player, try to install it ..."
|
|
|
|
echo "Check internet connection ..."
|
|
pingserver="raspbian.raspberrypi.org" ### var: pingcheck destination
|
|
if ! ping -q -c1 $pingserver>/dev/null; then
|
|
echo "No internet connection ..."
|
|
exit 0
|
|
fi
|
|
|
|
sudo apt-get update; sudo apt-get -y install $player_package
|
|
|
|
player_path="$(command -v $player)"
|
|
|
|
if [ -z "$player_path" ]; then
|
|
echo "Cannot install $player, exiting ..."
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
while true; do
|
|
|
|
mountstat="$(mount | grep $mountdevice)"
|
|
|
|
if [ -z "$mountstat" ]; then
|
|
folder="$folderint"
|
|
|
|
elif [ -n "$mountstat" ]; then
|
|
folder="$folderext"
|
|
|
|
fi
|
|
|
|
file="$(find "$folder" -maxdepth 1 -type f |sort -R |head -n1)"
|
|
|
|
while [ "$file" = "$oldfile" ]; do
|
|
file="$(find "$folder" -maxdepth 1 -type f |sort -R |head -n1)"
|
|
done
|
|
|
|
oldfile="$file"
|
|
$player $playerparam $file
|
|
|
|
done
|