Add 5-second delay after result video before signaling match end

- Match Qt player behavior: wait 5 seconds after result video ends
- Switch to black screen during the 5-second delay
- Send PLAY_VIDEO_RESULT_DONE after delay to allow results overlay to display
- Clear result data after the done message is sent
parent 9f15a7d3
...@@ -1429,18 +1429,48 @@ class RTSPStreamer(ThreadedComponent): ...@@ -1429,18 +1429,48 @@ class RTSPStreamer(ThreadedComponent):
} }
elif self.current_video_type == 'result': elif self.current_video_type == 'result':
# Switch to black screen first, then send PLAY_VIDEO_RESULT_DONE after 5 seconds
# This matches the Qt player behavior
logger.info(f"Result video completed - switching to black screen for 5 seconds before signaling done")
self._switch_to_black_screen()
# Schedule sending PLAY_VIDEO_RESULT_DONE message after 5 seconds (non-blocking)
# This allows the results overlay template to show results before sending the done message
if self.current_match_id and self.current_result: if self.current_match_id and self.current_result:
logger.info(f"Sending PLAY_VIDEO_RESULT_DONE") result_info = {
done_message = MessageBuilder.play_video_result_done( 'fixture_id': self.current_fixture_id,
sender=self.name, 'match_id': self.current_match_id,
fixture_id=self.current_fixture_id, 'result': self.current_result
match_id=self.current_match_id, }
result=self.current_result # Store result info for the delayed callback
) self._pending_result_done_info = result_info
self.message_bus.publish(done_message, broadcast=True)
# Clear result data after result video completes # Create a timer to send the done message after 5 seconds
self.result_data = None def send_result_done_after_delay():
try:
if hasattr(self, '_pending_result_done_info') and self._pending_result_done_info:
info = self._pending_result_done_info
logger.info(f"Sending PLAY_VIDEO_RESULT_DONE after 5 second delay")
done_message = MessageBuilder.play_video_result_done(
sender=self.name,
fixture_id=info['fixture_id'],
match_id=info['match_id'],
result=info['result']
)
self.message_bus.publish(done_message, broadcast=True)
self._pending_result_done_info = None
# Clear result data after result video completes
self.result_data = None
except Exception as e:
logger.error(f"Failed to send delayed result done message: {e}")
# Schedule the callback
result_done_timer = threading.Timer(5.0, send_result_done_after_delay)
result_done_timer.daemon = True
result_done_timer.start()
logger.info(f"Scheduled PLAY_VIDEO_RESULT_DONE in 5 seconds")
return # Don't switch to black screen again at the end of the function
elif self.current_video_type == 'intro': elif self.current_video_type == 'intro':
logger.warning("Intro video ended (should loop)") logger.warning("Intro video ended (should loop)")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment