From c52e97c23c9e46e3a6df19a087af39ec9f98a915 Mon Sep 17 00:00:00 2001 From: Scheianu Ionut Date: Sat, 10 May 2025 21:49:05 +0300 Subject: [PATCH] updated to chec silent for media on server --- src/media_player.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/media_player.py b/src/media_player.py index 0d18383..32a6fa9 100644 --- a/src/media_player.py +++ b/src/media_player.py @@ -30,6 +30,8 @@ class MediaPlayer(Screen): super(MediaPlayer, self).__init__(**kwargs) self.playlist = [] # Initialize the playlist self.current_index = 0 # Index of the currently playing media + self.updated_playlist = None # Store the updated playlist + self.is_playlist_update_pending = False # Flag to indicate a pending playlist update self.video_player = self.ids.video_player # Reference to the Video widget self.image_display = self.ids.image_display # Reference to the Image widget self.log_file = os.path.join(os.path.dirname(__file__), 'Resurse', 'log.txt') # Path to the log file @@ -192,6 +194,14 @@ class MediaPlayer(Screen): """Move to the next media in the playlist.""" Logger.info("Navigating to the next media.") self.current_index = (self.current_index + 1) % len(self.playlist) + + # Check if a playlist update is pending + if self.is_playlist_update_pending and self.current_index == 0: + Logger.info("Applying pending playlist update.") + self.playlist = self.updated_playlist # Apply the updated playlist + self.updated_playlist = None # Clear the updated playlist + self.is_playlist_update_pending = False # Reset the pending flag + self.play_media() def previous_media(self): @@ -260,10 +270,8 @@ class MediaPlayer(Screen): new_playlist = load_playlist() # Load the new playlist if new_playlist != self.playlist: # Compare the new playlist with the current one Logger.info("Playlist updated. Changes detected.") - self.playlist = new_playlist # Update the playlist - download_media_files(self.playlist) # Download new media files - clean_unused_files(self.playlist) # Remove unused files - self.play_media() # Restart media playback + self.updated_playlist = new_playlist # Store the updated playlist + self.is_playlist_update_pending = True # Mark the update as pending else: Logger.info("Playlist update skipped. No changes detected.")