Subj : New predicta.py code To : All From : paulie420 Date : Sun Sep 06 2020 14:01:39 This is what I've come up with for now, even tho it calls the older GPIO pin python version: ----- #!/usr/bin/python import RPi.GPIO as GPIO import time import os import random buttonPin = 21 directory = "/home/pi/Videos/" GPIO.setmode(GPIO.BCM) GPIO.setup(buttonPin, GPIO.IN) def playEpisode(): episode = random.choice(os.listdir(directory)) os.system('clear') cmd = "nohup omxplayer --aspect-mode stretch "+"'"+directory+episode+"' &" print('Playing:') print(episode) os.system('killall omxplayer.bin') os.system(cmd) try: GPIO.wait_for_edge(buttonPin, GPIO.FALLING) playEpisode() #point to location of this file os.system('sudo python/home/pi/predicta.py') except KeyboardInterrupt: GPIO.cleanup() ----- This version lets me press the button while a video is playing to get the next random video.... However now I have more I want to add. I want the code to just automatcally start playing random video after random video, and only play a different one when I press a button. (You don't want to HAVE to press the button all the time...) I think I'll be able to do that by just writing a while loop that plays random videos, unless (else) a button press, then it plays a new one... Oh, the joys of python. And I'm so green... |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) .