Fix app crash: resolve DISPLAY environment and input device issues
- Fixed start.sh environment variable loading from systemctl - Use here-document (<<<) instead of pipe for subshell to preserve exports - Added better error handling for evdev device enumeration - Added exception handling in intro video playback with detailed logging - App now properly initializes with DISPLAY=:0 and WAYLAND_DISPLAY=wayland-0
This commit is contained in:
+50
-26
@@ -105,7 +105,21 @@ class CardReader:
|
||||
return False
|
||||
|
||||
try:
|
||||
devices = [evdev.InputDevice(path) for path in evdev.list_devices()]
|
||||
try:
|
||||
devices = [evdev.InputDevice(path) for path in evdev.list_devices()]
|
||||
except Exception as e:
|
||||
Logger.warning(f"CardReader: Could not enumerate devices: {e}")
|
||||
Logger.info("CardReader: Trying alternative device enumeration...")
|
||||
# Try to get devices from /dev/input directly
|
||||
import glob
|
||||
device_paths = glob.glob('/dev/input/event*')
|
||||
devices = []
|
||||
for path in device_paths:
|
||||
try:
|
||||
devices.append(evdev.InputDevice(path))
|
||||
except Exception as dev_err:
|
||||
Logger.debug(f"CardReader: Could not open {path}: {dev_err}")
|
||||
continue
|
||||
|
||||
# Log all available devices for debugging
|
||||
Logger.info("CardReader: Scanning input devices...")
|
||||
@@ -903,7 +917,7 @@ class SignagePlayer(Widget):
|
||||
self.auto_resume_event = None # Track scheduled auto-resume
|
||||
self.config = {}
|
||||
self.playlist_version = None
|
||||
self.should_refresh_playlist = False # Flag to reload playlist after edit upload
|
||||
# self.should_refresh_playlist = False # Flag to reload playlist after edit upload (DISABLED - causing crashes)
|
||||
self.consecutive_errors = 0 # Track consecutive playback errors
|
||||
self.max_consecutive_errors = 10 # Maximum errors before stopping
|
||||
self.intro_played = False # Track if intro has been played
|
||||
@@ -1032,6 +1046,7 @@ class SignagePlayer(Widget):
|
||||
|
||||
def load_config(self):
|
||||
"""Load configuration from file"""
|
||||
Logger.debug("SignagePlayer: load_config() starting...")
|
||||
try:
|
||||
if os.path.exists(self.config_file):
|
||||
with open(self.config_file, 'r') as f:
|
||||
@@ -1165,13 +1180,14 @@ class SignagePlayer(Widget):
|
||||
|
||||
def play_intro_video(self):
|
||||
"""Play intro video on startup"""
|
||||
Logger.info(f"SignagePlayer: play_intro_video() called, intro_played={self.intro_played}")
|
||||
intro_path = os.path.join(self.resources_path, 'intro1.mp4')
|
||||
|
||||
if not os.path.exists(intro_path):
|
||||
Logger.warning(f"SignagePlayer: Intro video not found at {intro_path}")
|
||||
# Skip intro and load playlist
|
||||
self.intro_played = True
|
||||
self.check_playlist_and_play(None)
|
||||
Clock.schedule_once(self.check_playlist_and_play, 0.1)
|
||||
return
|
||||
|
||||
try:
|
||||
@@ -1189,18 +1205,34 @@ class SignagePlayer(Widget):
|
||||
|
||||
# Bind to video end event
|
||||
def on_intro_end(instance, value):
|
||||
if value == 'stop':
|
||||
Logger.info("SignagePlayer: Intro video finished")
|
||||
|
||||
# Mark intro as played before removing video
|
||||
self.intro_played = True
|
||||
|
||||
# Remove intro video
|
||||
if intro_video in self.ids.content_area.children:
|
||||
self.ids.content_area.remove_widget(intro_video)
|
||||
|
||||
# Start normal playlist immediately to reduce white screen
|
||||
self.check_playlist_and_play(None)
|
||||
try:
|
||||
if value == 'stop':
|
||||
Logger.info("SignagePlayer: Intro video finished")
|
||||
|
||||
# Mark intro as played before removing video
|
||||
self.intro_played = True
|
||||
|
||||
# Stop and unload the video properly
|
||||
try:
|
||||
instance.state = 'stop'
|
||||
instance.unload()
|
||||
except Exception as e:
|
||||
Logger.debug(f"SignagePlayer: Could not unload intro video: {e}")
|
||||
|
||||
# Remove intro video
|
||||
try:
|
||||
if intro_video in self.ids.content_area.children:
|
||||
self.ids.content_area.remove_widget(intro_video)
|
||||
except Exception as e:
|
||||
Logger.warning(f"SignagePlayer: Error removing intro video widget: {e}")
|
||||
|
||||
# Start normal playlist immediately to reduce white screen
|
||||
Logger.debug("SignagePlayer: Triggering playlist check after intro")
|
||||
self.check_playlist_and_play(None)
|
||||
except Exception as e:
|
||||
Logger.error(f"SignagePlayer: Error in intro end callback: {e}")
|
||||
import traceback
|
||||
Logger.error(f"SignagePlayer: Traceback: {traceback.format_exc()}")
|
||||
|
||||
intro_video.bind(state=on_intro_end)
|
||||
|
||||
@@ -1209,9 +1241,11 @@ class SignagePlayer(Widget):
|
||||
|
||||
except Exception as e:
|
||||
Logger.error(f"SignagePlayer: Error playing intro video: {e}")
|
||||
import traceback
|
||||
Logger.error(f"SignagePlayer: Traceback: {traceback.format_exc()}")
|
||||
# Skip intro and load playlist
|
||||
self.intro_played = True
|
||||
self.check_playlist_and_play(None)
|
||||
Clock.schedule_once(self.check_playlist_and_play, 0.1)
|
||||
|
||||
def check_playlist_and_play(self, dt):
|
||||
"""Check for playlist updates and ensure playback is running"""
|
||||
@@ -1219,16 +1253,6 @@ class SignagePlayer(Widget):
|
||||
if not self.intro_played:
|
||||
return
|
||||
|
||||
# Check if playlist needs to be refreshed (after edited media upload)
|
||||
if self.should_refresh_playlist:
|
||||
Logger.info("SignagePlayer: Reloading playlist due to edited media upload...")
|
||||
self.should_refresh_playlist = False
|
||||
self.load_playlist()
|
||||
# If we were playing, restart from current position
|
||||
if self.is_playing and self.playlist:
|
||||
self.play_current_media(force_reload=True)
|
||||
return
|
||||
|
||||
if not self.playlist:
|
||||
self.load_playlist()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user