updated to corect function the play pause function

This commit is contained in:
Kiwy Signage Player
2025-12-09 18:53:34 +02:00
parent 46d9fcf6e3
commit 87e059e0f4
5 changed files with 49 additions and 7 deletions

View File

@@ -1 +0,0 @@
User requested exit via password

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

View File

@@ -1397,6 +1397,7 @@ class SignagePlayer(Widget):
self.current_widget = None
self.is_playing = False
self.is_paused = False
self.auto_resume_event = None # Track scheduled auto-resume
self.config = {}
self.playlist_version = None
self.consecutive_errors = 0 # Track consecutive playback errors
@@ -1657,6 +1658,11 @@ class SignagePlayer(Widget):
def play_current_media(self):
"""Play the current media item"""
# Don't play if paused (unless we're explicitly resuming)
if self.is_paused:
Logger.debug(f"SignagePlayer: Skipping play_current_media - player is paused")
return
if not self.playlist or self.current_index >= len(self.playlist):
# End of playlist, restart
self.restart_playlist()
@@ -1840,7 +1846,7 @@ class SignagePlayer(Widget):
def next_media(self, dt=None):
"""Move to next media item"""
if self.is_paused:
Logger.debug(f"SignagePlayer: Skipping next_media - player is paused")
Logger.info(f"SignagePlayer: ⏸ Blocked next_media - player is paused")
return
Logger.info(f"SignagePlayer: Transitioning to next media (was index {self.current_index})")
@@ -1860,15 +1866,52 @@ class SignagePlayer(Widget):
self.play_current_media()
def toggle_pause(self, instance=None):
"""Toggle pause/play"""
"""Toggle pause/play with auto-resume after 5 minutes"""
self.is_paused = not self.is_paused
if self.is_paused:
self.ids.play_pause_btn.text = ''
# Paused - change icon to play and schedule auto-resume
Logger.info("SignagePlayer: ⏸ PAUSING - is_paused = True")
self.ids.play_pause_btn.background_normal = self.resources_path + '/play.png'
self.ids.play_pause_btn.background_down = self.resources_path + '/play.png'
Clock.unschedule(self.next_media)
# Cancel any existing auto-resume
if self.auto_resume_event:
Clock.unschedule(self.auto_resume_event)
# Schedule auto-resume after 5 minutes (300 seconds)
self.auto_resume_event = Clock.schedule_once(self.auto_resume_playback, 300)
Logger.info("SignagePlayer: Auto-resume scheduled in 5 minutes")
else:
self.ids.play_pause_btn.text = ''
# Resume by playing current media
# Playing - change icon to pause and cancel auto-resume
# Note: is_paused is already set to False by the toggle above
Logger.info("SignagePlayer: ▶ RESUMING - is_paused = False")
self.ids.play_pause_btn.background_normal = self.resources_path + '/pause.png'
self.ids.play_pause_btn.background_down = self.resources_path + '/pause.png'
# Cancel auto-resume if manually resumed
if self.auto_resume_event:
Clock.unschedule(self.auto_resume_event)
self.auto_resume_event = None
# Resume by playing current media (is_paused is now False)
self.play_current_media()
def auto_resume_playback(self, dt):
"""Automatically resume playback after 5 minutes of pause"""
Logger.info("SignagePlayer: Auto-resuming playback after 5 minutes")
self.auto_resume_event = None
if self.is_paused:
# Reset pause state FIRST (before calling play_current_media)
self.is_paused = False
# Update icon to pause
self.ids.play_pause_btn.background_normal = self.resources_path + '/pause.png'
self.ids.play_pause_btn.background_down = self.resources_path + '/pause.png'
# Resume playback (is_paused is now False so it will work)
self.play_current_media()
def restart_playlist(self):

View File

@@ -256,7 +256,7 @@
id: play_pause_btn
size_hint: None, None
size: dp(50), dp(50)
background_normal: root.resources_path + '/play.png'
background_normal: root.resources_path + '/pause.png'
background_down: root.resources_path + '/pause.png'
border: (0, 0, 0, 0)
on_press: root.toggle_pause()