The Raspberry Pi comes with an awesome little video player called Omxplayer that is very capable of playing back full 1080p video perfectly when encoded correctly in H.264/AAC. One problem is the current lack of playlist support in omxplayer, so this post explains how to create a bash script that will permanently loop through and play a directory of videos.
First install omxplayer:
sudo apt-get install omxplayer
Now create this script named for example “videoplayer.sh”:
#!/bin/sh # get rid of the cursor so we don't see it when videos are running setterm -cursor off # set here the path to the directory containing your videos VIDEOPATH="/mnt/storage/videos" # you can normally leave this alone SERVICE="omxplayer" # now for our infinite loop! while true; do if ps ax | grep -v grep | grep $SERVICE > /dev/null then sleep 1; else for entry in $VIDEOPATH/* do clear omxplayer $entry > /dev/null done fi done
Save the script, make it executable, and then run it as follows:
Obviously this is fairly basic – it just loops through a directory of videos and plays them one after another but in our case this was exactly what we wanted. It doesn’t even check that the files are actually video files although it would be easy to add this in. Regardless, it is hopefully a good starting point for more complex scripts.