Section One BBS

Welcome, Guest.


Subject: Python help... Date: Tue Sep 01 2020 04:43 pm
From: paulie420 To: All

I am working on a Raspberry Pi Zero project. Using a 1941 Philco Predicta
                                                                         televis
ion, that I fully refurbished, I want to c       reate 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 y
ou can set it          by some wood or small metal area and push a 'button'
                                                                           that 
do     esn'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 b
ox 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, b
ut 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 Rasp
berry Pi Zero holds videos... I want the python
                                               script to wait for a button (digt
al input device) press, play a random                                  video
                                                                            and 
then play another random video if I press the butt    on again. (I know, too,
                                                                             tha
t I'll have to put some kill proce   ss code in there... but I figured I'd
                                                                          get to
 that after I fig      ured out how to wait for next button press prior to
                                                                          video 
end      ing...)  
                  
                  Heres my current code:
                                        -----
                                             from gpiozero import DigitalInputDe
vice
    from time import sleep
import os
         import random
                      import subprocess
                                       
                                       button = DigitalInputDevice(21)
                                                                      
                                                                      while True
:
 # Setup Randon Videos
                          videoPath = "/home/pi/Videos/"
                                                            videoList = os.listd
ir(videoPath)
                 random.shuffle(videoList)
    for video in videoList:
                                    target = os.path.join(videoPath, video)
                                                                           # Wai
t for button press
                      print("Waiting for button press to start video.")
                                                                           butto
n.wait_for_active()
    os.system('omxplayer --aspect-mode stretch "{}" >
                                                     /dev/null'.format(target))
                                                                               
                                                                               #
subprocess.Popen('omxplayer --acpect-mode  stretch "{}" >
                                                         /dev/null'.format(targe
t))
   
   #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
                                                                           #list
ening again for a button press.
-----
     
     
     
     pAULIE42o
              .........
                       


Previous Message       Next Message
Replies: Re: Python help... (Tracker1)Re: Python help... (Nelgin)