Monday 8 September 2014

Getting a raspberry pi to show videos at start up.


A side project today at work was to get the Raspberry Pi to automatically display video files for our partner company.

The first part was getting the files to loop, I used the script from the learn adafruit site.

#!/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

That was the easy bit.

The more challenging part was to autoplay the script on startup. After a number of fruitless trials, I discovered the raspberrypi.stackexchange font of wisdom.

Basically all you need to do is to add a line calling the script into the /etc/xdg/lxsession/LXDE/autostart file.

@/home/pi/bin/videoplayer.sh

Knowing the SSH address of the pi is helpful to safely shutdown - or just pull the power ;-)


No comments:

Post a Comment