Reputation: 11
I cannot find a way to use omxplayer in a shell script to play videos in a folder in a random "shuffle" order. I would like it to loop through a "playlist" but so far I have only been able to find a way to play all folders in alphabetical order in a loop. I use a version of the code below for the loop.
#!/bin/sh
# get rid of the curso so we don't see it when videos are running
setterm -cursor off
# set here the path to the directory containing your videos
VIDEOPATH="/home/pi/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
Upvotes: 0
Views: 2603
Reputation: 11
I ended up combining the videos in Wondershare in various orders. This is not friendly to storage, because I essentially have several copies of the videos, but I can pick one of several orders to start playing and set it to loop which accomplishes most of my goal.
Loop code (much simpler than above code):
omxplayer -o local --loop /home/pi/video.mp4
Upvotes: 0