Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1264

Python • museum information board

$
0
0

Code:

import osimport timeimport subprocessimport RPi.GPIO as GPIOBUTTON_PIN = 17video_path = "/home/pi/media/video.mp4"waiting_screen_path = "/home/pi/Desktop/1.jpg"GPIO.setmode(GPIO.BCM)GPIO.setup(BUTTON_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)def show_waiting_screen():    os.system("pkill vlc")    os.system("pkill feh")    time.sleep(1)    os.system(f"feh --fullscreen {waiting_screen_path} &")def play_video():    video_process = subprocess.Popen(        ["cvlc", "--fullscreen", "--no-video-title-show", video_path],        stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL    )    video_process.wait()    os.system("pkill feh")def main():    while True:        show_waiting_screen()        GPIO.wait_for_edge(BUTTON_PIN, GPIO.FALLING)        play_video()        show_waiting_screen()if __name__ == "__main__":    try:        main()    except KeyboardInterrupt:        pass    finally:        GPIO.cleanup()
I want this code to work as follows: the waiting screen should be displayed first, then when the button is pressed, the video should play. After the video ends, the waiting screen should return. If the button is pressed again, the same loop should repeat .But it is not working please help me

Statistics: Posted by omar5858 — Fri Mar 14, 2025 12:36 pm



Viewing all articles
Browse latest Browse all 1264

Trending Articles