updated to play video

This commit is contained in:
2025-11-21 22:46:29 +02:00
parent da1d515cc5
commit 493f307599
2 changed files with 15 additions and 31 deletions

View File

@@ -1,4 +1,5 @@
kivy>=2.3.0
ffpyplayer
requests==2.32.4
bcrypt==4.2.1
aiohttp==3.9.1

View File

@@ -403,8 +403,6 @@ class SignagePlayer(Widget):
self.next_media()
return
Logger.info(f"SignagePlayer: Playing {file_name} for {duration}s")
# Remove status label if showing
self.ids.status_label.opacity = 0
@@ -465,10 +463,12 @@ class SignagePlayer(Widget):
self.next_media()
return
Logger.info(f"SignagePlayer: Loading video {os.path.basename(video_path)} for {duration}s")
# Create Video widget with optimized settings
self.current_widget = Video(
source=video_path,
state='stop', # Start stopped, then play after loaded
state='play', # Start playing immediately
options={
'eos': 'stop', # Stop at end of stream
},
@@ -480,13 +480,13 @@ class SignagePlayer(Widget):
# Bind to loaded and error events
self.current_widget.bind(loaded=self._on_video_loaded)
self.current_widget.bind(on_eos=self._on_video_eos)
# Add to content area
self.ids.content_area.add_widget(self.current_widget)
Logger.info(f"SignagePlayer: Playing {os.path.basename(video_path)} for {duration}s")
# Wait a bit for video to load, then start playing
Clock.schedule_once(lambda dt: self._start_video_playback(duration), 0.5)
# Schedule next media after duration
Clock.schedule_once(self.next_media, duration)
except Exception as e:
Logger.error(f"SignagePlayer: Error playing video {video_path}: {e}")
@@ -494,37 +494,20 @@ class SignagePlayer(Widget):
if self.consecutive_errors < self.max_consecutive_errors:
self.next_media()
def _start_video_playback(self, duration):
"""Start video playback after widget is loaded"""
try:
if self.current_widget and hasattr(self.current_widget, 'state'):
self.current_widget.state = 'play'
Logger.info("SignagePlayer: Video playback started")
# Schedule next media after duration
Clock.schedule_once(self.next_media, duration)
else:
Logger.error("SignagePlayer: Video widget not ready")
self.next_media()
except Exception as e:
Logger.error(f"SignagePlayer: Error starting video playback: {e}")
self.next_media()
def _on_video_error(self, instance, error):
"""Callback when video encounters an error"""
Logger.error(f"Video playback error: {error}")
Logger.error(f"Video source: {instance.source}")
Logger.error(f"Video state: {instance.state}")
# Try to skip to next media on error
Clock.schedule_once(self.next_media, 1)
def _on_video_eos(self, instance):
"""Callback when video reaches end of stream"""
Logger.info("SignagePlayer: Video finished playing (EOS)")
def _on_video_loaded(self, instance, value):
"""Callback when video is loaded - log video information"""
if value:
try:
Logger.info(f"Video loaded: {instance.texture.size if instance.texture else 'No texture'}")
Logger.info(f"Video duration: {instance.duration}s")
Logger.info(f"SignagePlayer: Video loaded successfully")
Logger.info(f"SignagePlayer: Video texture: {instance.texture.size if instance.texture else 'No texture'}")
Logger.info(f"SignagePlayer: Video duration: {instance.duration}s")
Logger.info(f"SignagePlayer: Video state: {instance.state}")
except Exception as e:
Logger.debug(f"Could not log video info: {e}")
Logger.warning(f"SignagePlayer: Could not log video info: {e}")
def play_image(self, image_path, duration):
"""Play an image file"""