An acquaintance needed a video kiosk that plays looping videos for an exposition booth. Since I have a bunch of Raspberry Pis lying around, I figured that it would be the perfect use case for using one of them.
Let's assume we start from scratch, with a unflashed, brand new SD card and your Raspberry Pi.
Install a version of Raspbian that includes the desktop. You can head over to : https://www.raspberrypi.org/downloads/raspbian/ and follow the instructions.
Once the image is downloaded, you can burn it to your SD card with tools like Etcher (https://www.balena.io/etcher/)
Let's configure your raspberry to connect automatically to your Wifi.
Create a file named wpa_supplicant.conf
that has the following content :
country=<COUNTRY_CODE>
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="Your Wi-Fi network name"
psk="Your Wi-Fi network password"
}
Make sure to update the country
, ssid
and psk
keys.
Insert the SD card in your computer and copy the wpa_supplicant.conf
file at the root of the boot
volume of the SD card.
To enable SSH access add an empty file ssh
also placed at the root of the boot
volume on your SD card.
Insert the SD card in your raspberry Pi : You should now have SSH access to your Raspberry Pi. By default, its hostname will be raspberrypi.local.
Download the video you want to play on your booth.
Since we will be using vlc
(https://www.videolan.org/vlc/), your video should have a format that is supported by vlc
.
Open up a terminal, and you can copy the video to your Pi with the following command :
scp path_to_your_video/your_video.mp4 [email protected]:~
This will copy your video to the home directory of your Raspberry Pi.
We are going to create a background job that your operating system will launch at each boot of your Pi. To do so, we are creating a systemd unit file that will have this content :
[Unit]
Description=videokiosk
[Service]
User=pi
Environment="DISPLAY=:0"
ExecStart=/usr/bin/vlc -Rf path_to_your_video.mp4
WorkingDirectory=/home/pi
Restart=always
[Install]
WantedBy=multi-user.target
We created a systemd service that we call videokiosk
.
- We add a
User
field as VLC is not supposed to be started as the root user. - We add an environment variable called
DISPLAY
so that the video plays on the HDMI output of the Pi. - We use the
-Rf
flag in thevlc
command so that the video plays in full screen and on repeat.
Connect to your raspberry Pi over ssh :
ssh [email protected]
Use your favorite text editor to create the unit file :
sudo nano /etc/systemd/system/videokiosk.service
Copy/Paste the unit file we described earlier. Enable the service to auto-start on boot.
sudo systemctl enable videokiosk.service
To start the service :
sudo systemctl start videokiosk.service
To view the latest logs, use sudo journalctl -xfu videokiosk.service
To view the current service status, use sudo systemctl status videokiosk.service
You should be good to go !!
I had to use
cvlc
, other than that it works perfectly