diff --git a/display_test_nexio.py b/display_test_nexio.py index 3fab83d..0fbaa18 100644 --- a/display_test_nexio.py +++ b/display_test_nexio.py @@ -1,5 +1,5 @@ import gi -import signal +import signal # for signal.SIGUSR1 constant import struct import os @@ -131,7 +131,8 @@ def play_kiosk(): pipeline.set_property("uri", manager.videos[0]) # SIGUSR1 → switch video (used by device_server PUT /display {"state":"on"}) - signal.signal(signal.SIGUSR1, lambda sig, frame: manager.switch_video()) + GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGUSR1, + lambda: manager.switch_video() or True) # --- INPUT MONITORING --- try: @@ -151,13 +152,16 @@ def play_kiosk(): def on_message(bus, msg, manager_instance): if msg.type == Gst.MessageType.EOS: - # Video ended. cycle LED and loop back to start manager_instance.change_led_colour() pipeline.seek_simple(Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT, 0) elif msg.type == Gst.MessageType.ERROR: err, debug = msg.parse_error() - print(f"GStreamer Error: {err}") - loop.quit + print(f"GStreamer Error: {err}\nDebug: {debug}", flush=True) + loop.quit() + elif msg.type == Gst.MessageType.STATE_CHANGED: + if msg.src == pipeline: + old, new, _ = msg.parse_state_changed() + print(f"Pipeline: {old.value_nick} -> {new.value_nick}", flush=True) bus.connect("message", on_message, manager)