I have a Raspberry Pi 3B with a Python3 code running 24/7.
Right now, I'm running Raspbian Stretch desktop on console mode with no I/O. I only connect a screen via HDMI and an USB keyboard for debugging.
To make the code run automatically everytime I plug the Raspberry, I have this lines at the end of the file
/home/pi/.bashrc (this makes the program run everytime you open a terminal, so this runs on foreground everytime I boot on console mode):
cd /MyCodePath sudo python3 main.py
Now I want to connect an HDMI screen and I want it to display some image or video instead of displaying the output of my program.
I have seen someone using Kivy to do something kinda similar, but it seems too big and hard to learn (I think is not worth just to do what I want).
Is there an "easy" way to do this?
I tried calling omxplayer in infinite loop, but the problem is that everytime the video reachs its end and restarts, the console is seen for a second. I know how to make the console look just black (doing a
clear, not having any Python output and changing the prompt color to black), but it still blinks everytime the video ends and starts again.
call_args = "omxplayer /video_path/my_video.mp4".split() while True: subprocess.call(call_args)
I'll keep looking for better solutions, this isn't enough at all.
Okay so adding
--loop to the omxplayer command works fine, but now I don't know how to stop it when I app closes naturally. I tried this but doesn't seem to work:
pkill omxplayer killall omxplayer
Also the python3 code I'm using now to launch omxplayer is this one:
@staticmethod def start_loop(): path = "/video_path/my_video.mp4" omx = "omxplayer --no-osd -b -o local --loop " if os.path.isfile(path): os.system(omx + user_path + " &")