final app

This commit is contained in:
2025-04-01 10:52:29 +03:00
parent 1c504c7289
commit 64a02263c3
4 changed files with 3407 additions and 6 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -50,12 +50,12 @@
size_hint: None, None size_hint: None, None
size: 75, 75 size: 75, 75
pos_hint: {'right': 0.88, 'bottom': 0.98} pos_hint: {'right': 0.88, 'bottom': 0.98}
background_normal: './Resurse/play.png' background_normal: './Resurse/play.png' # Initial state
background_down: './Resurse/pause.png' background_down: './Resurse/play.png' # Initial state
background_color: 1, 1, 1, 0.9 # Temporary blue background for debugging background_color: 1, 1, 1, 0.9 # White with 90% transparency
border: [0, 0, 0, 0] # Remove the default border border: [0, 0, 0, 0]
opacity: 1 opacity: 1
on_press: root.toggle_play_pause() on_press: root.manage_play_pause_state() # Call the new function
# Left Arrow button # Left Arrow button
Button: Button:

View File

@@ -34,6 +34,8 @@ class MediaPlayer(Screen):
self.image_display = self.ids.image_display # Reference to the Image 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 self.log_file = os.path.join(os.path.dirname(__file__), 'Resurse', 'log.txt') # Path to the log file
self.is_paused = False # Track the state of the play/pause button self.is_paused = False # Track the state of the play/pause button
self.reset_timer = None # Timer to reset the button state after 3 minutes
self.image_timer = None # Timer for scheduling the next media for images
# Schedule periodic updates to check for playlist updates # Schedule periodic updates to check for playlist updates
Clock.schedule_interval(self.check_playlist_updates, 300) # Every 5 minutes Clock.schedule_interval(self.check_playlist_updates, 300) # Every 5 minutes
@@ -192,7 +194,7 @@ class MediaPlayer(Screen):
fade_in.start(self.image_display) # Start the fade-in animation fade_in.start(self.image_display) # Start the fade-in animation
# Schedule the next media after the duration # Schedule the next media after the duration
Clock.schedule_once(self.next_media, duration) self.image_timer = Clock.schedule_once(self.next_media, duration)
def next_media(self, dt=None): def next_media(self, dt=None):
"""Move to the next media in the playlist.""" """Move to the next media in the playlist."""
@@ -208,20 +210,59 @@ class MediaPlayer(Screen):
def toggle_play_pause(self): def toggle_play_pause(self):
"""Toggle the play/pause button state and update its appearance.""" """Toggle the play/pause button state and update its appearance."""
self.manage_play_pause_state()
def manage_play_pause_state(self):
"""Manage the state of the play/pause button and media playback."""
if self.is_paused: if self.is_paused:
Logger.info("Resuming media playback.") Logger.info("Resuming media playback.")
self.video_player.state = 'play' self.video_player.state = 'play'
# Resume the image timer if it exists
if self.image_timer:
Logger.info("Resuming image timer.")
self.image_timer()
# Update the button to indicate the playing state # Update the button to indicate the playing state
self.ids.play_pause_button.background_down = './Resurse/play.png' self.ids.play_pause_button.background_down = './Resurse/play.png'
self.ids.play_pause_button.background_normal = './Resurse/play.png'
# Cancel the reset timer if it exists
if self.reset_timer:
Clock.unschedule(self.reset_timer)
else: else:
Logger.info("Pausing media playback.") Logger.info("Pausing media playback.")
self.video_player.state = 'pause' self.video_player.state = 'pause'
# Pause the image timer if it exists
if self.image_timer:
Logger.info("Pausing image timer.")
Clock.unschedule(self.image_timer)
# Update the button to indicate the paused state # Update the button to indicate the paused state
self.ids.play_pause_button.background_down = './Resurse/pause.png' self.ids.play_pause_button.background_down = './Resurse/pause.png'
self.ids.play_pause_button.background_normal = './Resurse/pause.png'
# Start a timer to reset the button state after 3 minutes
self.reset_timer = Clock.schedule_once(self.reset_play_pause_state, 180)
# Toggle the state # Toggle the state
self.is_paused = not self.is_paused self.is_paused = not self.is_paused
def reset_play_pause_state(self, dt):
"""Reset the play/pause button state to 'play' after 3 minutes."""
Logger.info("Resetting play/pause button state to 'play' after timeout.")
self.is_paused = False
self.video_player.state = 'play'
# Resume the image timer if it exists
if self.image_timer:
Logger.info("Resuming image timer.")
self.image_timer()
self.ids.play_pause_button.background_down = './Resurse/play.png'
self.ids.play_pause_button.background_normal = './Resurse/play.png'
def check_playlist_updates(self, dt): def check_playlist_updates(self, dt):
"""Check for updates to the playlist.""" """Check for updates to the playlist."""
new_playlist = load_playlist() # Load the new playlist new_playlist = load_playlist() # Load the new playlist

Binary file not shown.