Subj : Python help... To : All From : paulie420 Date : Tue Sep 01 2020 16:43:43 I am working on a Raspberry Pi Zero project. Using a 1941 Philco Predicta television, that I fully refurbished, I want to create some python code to play a random video with a digital touch sensor module. The digital touch sensory module is a bit different from a push button, because you can set it by some wood or small metal area and push a 'button' that doesn't appear to be there. Thats important, because I don't want to modify this antique in any way... Ok, so anyway... I have python randomizing the files... I have it using omxplayer to play a video... but then python/the linux box just sits there with the video player - not waiting for the next button press until the video is completely over. I thought I could use subprocess.Popen instead of os.system, but I haven't figured out if that it true - nor the correct syntax to doso. Anyone wanna look at my code and see if they can help? Again, the setup is Raspberry Pi Zero holds videos... I want the python script to wait for a button (digtal input device) press, play a random video and then play another random video if I press the button again. (I know, too, that I'll have to put some kill process code in there... but I figured I'd get to that after I figured out how to wait for next button press prior to video ending...) Heres my current code: ----- from gpiozero import DigitalInputDevice from time import sleep import os import random import subprocess button = DigitalInputDevice(21) while True: # Setup Randon Videos videoPath = "/home/pi/Videos/" videoList = os.listdir(videoPath) random.shuffle(videoList) for video in videoList: target = os.path.join(videoPath, video) # Wait for button press print("Waiting for button press to start video.") button.wait_for_active() os.system('omxplayer --aspect-mode stretch "{}" > /dev/null'.format(target)) #subprocess.Popen('omxplayer --acpect-mode stretch "{}" > /dev/null'.format(target)) #The subprocess was my idea that would let python continue listening... but #didnt work YET. The os.system does play a video... just waits there before #listening again for a button press. ----- |07p|15AULIE|1142|07o |08......... --- Mystic BBS v1.12 A45 2020/02/18 (Raspberry Pi/32) * Origin: 2o fOr beeRS bbs>>>20ForBeers.com:1337 (1337:3/129) .