Proinsias
Posts: 26
Joined: Fri Jan 11, 2013 1:06 am
Location: Scotland

Video player - Play on Boot

Fri Oct 19, 2018 9:46 pm

Goal:

RPi 2 connected via hdmi to a TV which starts playing video on boot. Preferably able to run a randomized infinite loop of video files stored locally.
The idea being that switching on the plug to the TV/Pi socket is enough to keep the Pi playing movies indefinitely until power is cut and there is no need for any user input.

My plan was to use Alpine & omxplayer, it's fast light and the live/readonly nature of the install seems ideal where the only interaction is the power going on or off. But after an hour or so last night I'm struggling with the very basics. OMXplayer doesn't seem keen to play more than one file at a time alongside the lack of any random or loop options.

I've had a quick duckduckgo around Kodi, been a while since I used, and couldn't see a simple solution.

Any ideas?

User avatar
topguy
Posts: 5007
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Video player - Play on Boot

Sat Oct 20, 2018 8:50 pm

Welcome to the world of shell/bash scripting.

How to repeatedly pick a file at random from a directory and do something with it.

Code: Select all

#!/bin/bash

while true
do
  filename=$(ls Videos | shuf -n 1)
  ls -l Videos/$filename
  sleep 2
done


Proinsias
Posts: 26
Joined: Fri Jan 11, 2013 1:06 am
Location: Scotland

Re: Video player - Play on Boot [SOLVED]

Sun Oct 21, 2018 10:06 pm

Thank you.

I created randomvideo.sh:

Code: Select all

#!/bin/sh

while true
do
  filename=$(ls /mnt/storage | shuf -n 1)
  omxplayer /mnt/storage/"$filename"
  sleep 2
done
which starts on login called from ~/.profile:

Code: Select all

/home/user/randomvideo.sh
Still working on autologin. I've been trying some examples from /etc/inittab but haven't got it working yet.

*edit*

autologin now working too.
I installed util-linux, which provides agetty, instead of busybox getty & ammended /etc/inittab:

Code: Select all

# Set up a couple of getty's
tty1::respawn:-/sbin/agetty --noclear -a username -n 38400 tty1
tty2::respawn:/sbin/getty 38400 tty2
tty3::respawn:/sbin/getty 38400 tty3
Would be nice to have autologin without needing util-linux/agetty but it is working, which is nice.

User avatar
topguy
Posts: 5007
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Video player - Play on Boot

Mon Oct 22, 2018 10:13 am

I dont know what "Alpine" is, you are not running Raspbian ?

Return to “Media centres”