Python Forum

Full Version: run code while playing video
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am new to python, and been reading and i think i am in the right direction, just not sure.

I am trying to start executing code and without waiting start playing a video (So the video plays while the code is being ran)

I was using os.system and learned to not use that but instead subprocess

The code from the Test.py runs with no issue if I run without the subproccess.Popen line
the code from the bgrun.py runs fine by itself.

If I run them together I seems as if I have to hit enter for the video portion to finish and not even sure if the bgrun.py was executed as the screen stays black.

Goal:
Have video play and in background
Shutdown emulationstation
sync to make sure there is no more data beign written to drives
once vidoe is finished playing then shutdown

Video will be 5-10 seconds long

here is what I have come up with so far.

Main file (Test.py)
import subprocess
subprocess.Popen(["rm","-r","/bgrun.py"])
subprocess.call('pkill omxplayer',shell=True)
subprocess.call('omxplayer -r /shutdown.mp4',shell=True)
subprocess.call('reset', shell=True)
subprocess.call('echo Safe to shutdown', shell=True)
#subprocess.call('sudo shutdown -h now',shell=True)#commented out while testing
Sub file (bgrun.py)
import subprocess
subprocess.call('sudo killall emulationstation',shell=True)
subprocess.call('sudo sync', shell=True)