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: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):
"""Play the current media in the playlist."""
if self.playlist:
media = self.playlist[self.current_index] # Get the current media
file_name = media.get('file_name', '') # Get the file name
file_extension = os.path.splitext(file_name)[1].lower() # Get the file extension
duration = media.get('duration', 10) # Get the duration (default: 10 seconds)
if not self.playlist or not isinstance(self.playlist, list):
Logger.error("MediaPlayer: Playlist is invalid or empty. Cannot play media.")
return
# 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
media = self.playlist[self.current_index] # Get the current media
file_name = media.get('file_name', '') # Get the file name
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
if not os.path.exists(file_path):
Logger.error(f"Media file not found: {file_path}")
return
Logger.info(f"Playing media: {file_path}")
# Cancel any existing timers
if self.image_timer:
Logger.info("Canceling existing image timer.")
Clock.unschedule(self.image_timer)
# Check if the file exists
if not os.path.exists(file_path):
Logger.error(f"Media file not found: {file_path}")
return
# Log the start of the media
self.log_event(file_name, "STARTED")
# Cancel any existing timers
if self.image_timer:
Logger.info("Canceling existing image timer.")
Clock.unschedule(self.image_timer)
# Determine the type of media and play it
if file_extension in ['.mp4', '.avi', '.mov']:
self.play_video(file_path) # Play video
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}")
# Log the start of the media
self.log_event(file_name, "STARTED")
# Determine the type of media and play it
if file_extension in ['.mp4', '.avi', '.mov']:
self.play_video(file_path) # Play video
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):
"""Play a video file without a fade-in effect."""