update player with wachdog and intro
This commit is contained in:
40
src/main.py
40
src/main.py
@@ -91,6 +91,19 @@ class ExitPasswordPopup(Popup):
|
||||
if entered_password == correct_password:
|
||||
# Password correct, exit app
|
||||
Logger.info("ExitPasswordPopup: Correct password, exiting app")
|
||||
|
||||
# Create stop flag to prevent watchdog restart
|
||||
stop_flag = os.path.join(
|
||||
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
|
||||
'.player_stop_requested'
|
||||
)
|
||||
try:
|
||||
with open(stop_flag, 'w') as f:
|
||||
f.write('User requested exit via password')
|
||||
Logger.info("ExitPasswordPopup: Stop flag created - watchdog will not restart")
|
||||
except Exception as e:
|
||||
Logger.warning(f"ExitPasswordPopup: Could not create stop flag: {e}")
|
||||
|
||||
self.dismiss()
|
||||
App.get_running_app().stop()
|
||||
else:
|
||||
@@ -285,6 +298,7 @@ class SignagePlayer(Widget):
|
||||
self.playlists_dir = os.path.join(self.base_dir, 'playlists')
|
||||
self.config_file = os.path.join(self.config_dir, 'app_config.json')
|
||||
self.resources_path = os.path.join(self.config_dir, 'resources')
|
||||
self.heartbeat_file = os.path.join(self.base_dir, '.player_heartbeat')
|
||||
# Create directories if they don't exist
|
||||
for directory in [self.config_dir, self.media_dir, self.playlists_dir]:
|
||||
os.makedirs(directory, exist_ok=True)
|
||||
@@ -299,11 +313,22 @@ class SignagePlayer(Widget):
|
||||
self.controls_timer = None
|
||||
# Auto-hide controls
|
||||
self.schedule_hide_controls()
|
||||
# Start heartbeat monitoring
|
||||
Clock.schedule_interval(self.update_heartbeat, 10) # Update every 10 seconds
|
||||
|
||||
def _update_size(self, instance, value):
|
||||
self.size = value
|
||||
if hasattr(self, 'ids') and 'content_area' in self.ids:
|
||||
self.ids.content_area.size = value
|
||||
|
||||
def update_heartbeat(self, dt):
|
||||
"""Update heartbeat file to indicate player is alive"""
|
||||
try:
|
||||
# Touch the heartbeat file to update its modification time
|
||||
with open(self.heartbeat_file, 'w') as f:
|
||||
f.write(str(time.time()))
|
||||
except Exception as e:
|
||||
Logger.warning(f"SignagePlayer: Failed to update heartbeat: {e}")
|
||||
|
||||
def initialize_player(self, dt):
|
||||
"""Initialize the player - load config and start playlist checking"""
|
||||
@@ -983,4 +1008,17 @@ class SignagePlayerApp(App):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
SignagePlayerApp().run()
|
||||
try:
|
||||
Logger.info("=" * 80)
|
||||
Logger.info("Starting Kivy Signage Player Application")
|
||||
Logger.info("=" * 80)
|
||||
SignagePlayerApp().run()
|
||||
except KeyboardInterrupt:
|
||||
Logger.info("Application stopped by user (Ctrl+C)")
|
||||
except Exception as e:
|
||||
Logger.critical(f"Fatal error in application: {e}")
|
||||
Logger.exception("Full traceback:")
|
||||
import sys
|
||||
sys.exit(1)
|
||||
finally:
|
||||
Logger.info("Application shutdown complete")
|
||||
Reference in New Issue
Block a user