Python Forum
run code while playing video
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
run code while playing video
#1
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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How would I be able to detect a media player app playing a video. phpjunkie 2 526 Oct-16-2023, 02:09 PM
Last Post: phpjunkie
  Problem with code / audio is playing randomly, not matching csv requirements Daniel_kcr 2 579 Sep-07-2023, 05:09 PM
Last Post: deanhystad
  Video recording with Raspberry Pi - What´s wrong with my python code? Montezuma1502 3 1,180 Feb-24-2023, 06:14 PM
Last Post: deanhystad
  Python + OpenCV + Tkinter playing video help Hanban 1 17,915 May-08-2017, 01:25 AM
Last Post: Joseph_f2

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020