updated to chec silent for media on server
This commit is contained in:
@@ -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.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user