final update

This commit is contained in:
2025-06-20 16:35:43 +03:00
parent 9fe4c419d7
commit f5ba9e734f
2 changed files with 34 additions and 26 deletions

View File

@@ -1,2 +1,7 @@
2025-06-20 16:32:40 - STARTED: edit_pencil.png 2025-06-20 16:32:40 - STARTED: edit_pencil.png
2025-06-20 16:33:00 - STARTED: delete.png 2025-06-20 16:33:00 - STARTED: delete.png
2025-06-20 16:35:13 - STARTED: edit_pencil.png
2025-06-20 16:35:15 - STARTED: delete.png
2025-06-20 16:35:16 - STARTED: edit_pencil.png
2025-06-20 16:35:17 - STARTED: delete.png
2025-06-20 16:35:18 - STARTED: edit_pencil.png

View File

@@ -186,38 +186,41 @@ class MediaPlayer(Screen):
def play_media(self): def play_media(self):
"""Play the current media in the playlist.""" """Play the current media in the playlist."""
if self.playlist: if not self.playlist or not isinstance(self.playlist, list):
media = self.playlist[self.current_index] # Get the current media Logger.error("MediaPlayer: Playlist is invalid or empty. Cannot play media.")
file_name = media.get('file_name', '') # Get the file name return
file_extension = os.path.splitext(file_name)[1].lower() # Get the file extension
duration = media.get('duration', 10) # Get the duration (default: 10 seconds)
# Define the base directory for media files media = self.playlist[self.current_index] # Get the current media
base_dir = os.path.join(os.path.dirname(__file__), 'static', 'resurse') file_name = media.get('file_name', '') # Get the file name
file_path = os.path.join(base_dir, file_name) # Full path to the media file file_extension = os.path.splitext(file_name)[1].lower() # Get the file extension
duration = media.get('duration', 10) # Get the duration (default: 10 seconds)
Logger.info(f"Playing media: {file_path}") # Define the base directory for media files
base_dir = os.path.join(os.path.dirname(__file__), 'static', 'resurse')
file_path = os.path.join(base_dir, file_name) # Full path to the media file
# Check if the file exists Logger.info(f"Playing media: {file_path}")
if not os.path.exists(file_path):
Logger.error(f"Media file not found: {file_path}")
return
# Cancel any existing timers # Check if the file exists
if self.image_timer: if not os.path.exists(file_path):
Logger.info("Canceling existing image timer.") Logger.error(f"Media file not found: {file_path}")
Clock.unschedule(self.image_timer) return
# Log the start of the media # Cancel any existing timers
self.log_event(file_name, "STARTED") if self.image_timer:
Logger.info("Canceling existing image timer.")
Clock.unschedule(self.image_timer)
# Determine the type of media and play it # Log the start of the media
if file_extension in ['.mp4', '.avi', '.mov']: self.log_event(file_name, "STARTED")
self.play_video(file_path) # Play video
elif file_extension in ['.jpg', '.jpeg', '.png', '.gif']: # Determine the type of media and play it
self.show_image(file_path, duration) # Show image if file_extension in ['.mp4', '.avi', '.mov']:
else: self.play_video(file_path) # Play video
Logger.error(f"Unsupported media type for file: {file_name}") elif file_extension in ['.jpg', '.jpeg', '.png', '.gif']:
self.show_image(file_path, duration) # Show image
else:
Logger.error(f"Unsupported media type for file: {file_name}")
def play_video(self, file_path): def play_video(self, file_path):
"""Play a video file without a fade-in effect.""" """Play a video file without a fade-in effect."""