Write a bash script that goes something like this:

while true
do
  killall -9 vlc
	cvlc --loop --random --no-video-title-show (--no-osd) /home/pi/Videos/* &
	sleep 1h
done

Let’s break down each line:

  1. while true : Start an infinite loop which runs continuously, without any conditions for termination.
  2. do : Marks the beginning of the loop body.
  3. killall -9 vlc : Forcefully kill all running instances of VLC Media Player on the system. The -9 option sends SIGKILL signal to terminate the processes immediately, without any graceful shutdown.
  4. cvlc --loop --random --no-video-title-show (--no-osd) /home/pi/Videos/* & : Start a new instance of VLC Media Player with specific options:
    • --loop : Makes the player loop the playlist continuously.
    • --random : Plays the media files in a random order from the specified directory.
    • (--no-video-title-show) : Hides the video title on the screen while playing.
    • --no-osd : Disables the on-screen display (OSD) during playback, which includes features like progress bar and elapsed time.
    • /home/pi/Videos/* : A wildcard pattern that matches all files under the /home/pi/Videos directory, making it the media source for VLC to play. The & symbol at the end runs this command in the background and returns control back to the script immediately, allowing it to continue with the next iteration of the loop.
  5. sleep 1h : Makes the script wait for one hour before starting the next iteration of the loop. After an hour, the script kills all running instances of VLC Media Player, starts a new instance, and repeats the process.