Subj : Python help...
To : All
From : paulie420
Date : Tue Sep 01 2020 04:43 pm
[0m[1;1H[1mI am working on a Raspberry Pi Zero project. Using a 1941 Phil
[A[62Cco Predicta[B[73Dtelevision, that I fully refurbished, I want to c
[A[49Create some python code to[B[74Dplay a random video with a digital
[A[35Ctouch sensor module.[B[55D[B[1DThe digital touch sensory module
[A[33Cis a bit different from a push button,[B[71Dbecause you can set it
[A[22C by some wood or small metal area and push a 'button'[B[75Dthat do
[A[7Cesn't appear to be there. Thats important, because I don't want to
modify this antique in any way...[B[33D[B[1DOk, so anyway... I have pyth
[A[28Con randomizing the files... I have it using[B[71Domxplayer to play
[A[17C a video... but then python/the linux box just sits there[B[74Dwit
[A[3Ch the video player - not waiting for the next button press until the
[A[72Cvideo[B[77Dis completely over. [B[20D[B[1DI thought I could u
[A[19Cse subprocess.Popen instead of os.system, but I haven't[B[74Dfigur
[A[5Ced out if that it true - nor the correct syntax to doso.[B[61D
Anyone wanna look at my code and see if they can help? [B[55DAgain, the s
[A[12Cetup is Raspberry Pi Zero holds videos... I want the python[B[71Ds
[A[1Ccript to wait for a button (digtal input device) press, play a random
[A[70C video[B[76Dand then play another random video if I press the butt
[A[54Con again. (I know, too,[B[77Dthat I'll have to put some kill proce
[A[37Css code in there... but I figured I'd[B[74Dget to that after I fig
[A[23Cured out how to wait for next button press prior to[B[74Dvideo end
[A[9Cing...) [B[17D[B[1DHeres my current code:[B[22D-----[B[5Dfro
[A[3Cm gpiozero import DigitalInputDevice[B[39Dfrom time import sleep
import os[B[9Dimport random[B[13Dimport subprocess[B[17D[B[1Dbutton
[A[7C= DigitalInputDevice(21)[B[31D[B[1Dwhile True:[B[11D# Setup Ran
[A[11Cdon Videos[B[21D[4CvideoPath = "/home/pi/Videos/"[B[34D[4Cvide
[A[8CoList = os.listdir(videoPath)[B[37D[4Crandom.shuffle(videoList)
[4Cfor video in videoList:[B[27D[9Ctarget = os.path.join(videoPath, vide
[A[46Co)[B[48D# Wait for button press[B[23D[4Cprint("Waiting for butt
[A[27Con press to start video.")[B[53D[4Cbutton.wait_for_active()
[4Cos.system('omxplayer --aspect-mode stretch "{}" >[B[53D/dev/null'.form
[A[15Cat(target))[B[26D[B[1D#subprocess.Popen('omxplayer --acpect-mode
[A[42C stretch "{}" >[B[57D/dev/null'.format(target))[B[26D[B[1D#The
[A[4C subprocess was my idea that would let python continue listening... b
[A[73Cut [B[76D#didnt work YET. The os.system does play a video... just
[A[56C waits there before[B[75D#listening again for a button press.
-----[B[5D[B[1D[B[1D[B[1D[0mp[1mAULIE[36m42[0mo[B[9D[1;30m...
[A[3C......[B[9D