|
|
|
|
@ -173,7 +173,6 @@ def wait_for_button_press(video_info):
|
|
|
|
|
no_press_count = 0
|
|
|
|
|
print(f"Restarting service: {service_name}")
|
|
|
|
|
subprocess.run(["sudo", "systemctl", "restart", service_name], check=True)
|
|
|
|
|
restart_service(service_name)
|
|
|
|
|
print(f"Service {service_name} restarted successfully.")
|
|
|
|
|
exit()
|
|
|
|
|
else:
|
|
|
|
|
@ -185,12 +184,23 @@ def wait_for_button_press(video_info):
|
|
|
|
|
print("No next video available. Restarting from Video 1.")
|
|
|
|
|
print(f"Restarting service: {service_name}")
|
|
|
|
|
subprocess.run(["sudo", "systemctl", "restart", service_name], check=True)
|
|
|
|
|
restart_service(service_name)
|
|
|
|
|
print(f"Service {service_name} restarted successfully.")
|
|
|
|
|
exit()
|
|
|
|
|
|
|
|
|
|
time.sleep(0.1) # Small delay to reduce CPU usage
|
|
|
|
|
|
|
|
|
|
# Function to deactivate all buttons and LEDs
|
|
|
|
|
def deactivate_all_buttons_and_leds():
|
|
|
|
|
print("Deactivating all buttons and LEDs...")
|
|
|
|
|
# Deactivate all buttons
|
|
|
|
|
for button in buttons:
|
|
|
|
|
GPIO.setup(button, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
|
|
|
|
# Turn off all LEDs
|
|
|
|
|
for led in leds:
|
|
|
|
|
GPIO.output(led, GPIO.LOW)
|
|
|
|
|
time.sleep(0.1) # Ensure all GPIO changes take effect
|
|
|
|
|
print("All buttons and LEDs deactivated.")
|
|
|
|
|
|
|
|
|
|
# Function to handle the video chain
|
|
|
|
|
def handle_video_chain(video_id):
|
|
|
|
|
video_info = video_paths.get(video_id)
|
|
|
|
|
@ -203,6 +213,7 @@ def handle_video_chain(video_id):
|
|
|
|
|
play_video(video_info["video"], loop=True)
|
|
|
|
|
else:
|
|
|
|
|
play_video(video_info["video"], loop=False)
|
|
|
|
|
deactivate_all_buttons_and_leds()
|
|
|
|
|
activate_before_video_ends(video_info)
|
|
|
|
|
wait_for_button_press(video_info)
|
|
|
|
|
|
|
|
|
|
|