Fix template rotation: stop rotation during match video, show results after match

parent eda13efa
......@@ -10698,13 +10698,22 @@ def get_overlay_data():
headless_player = getattr(main_app, 'headless_player', None)
if headless_player and hasattr(headless_player, 'overlay_data'):
overlay_data = headless_player.overlay_data.copy() if headless_player.overlay_data else {}
# Add match video state for template switching
if hasattr(headless_player, 'is_playing_match_video'):
overlay_data['is_playing_match_video'] = headless_player.is_playing_match_video
if hasattr(headless_player, 'current_match_video_filename'):
overlay_data['current_match_video_filename'] = headless_player.current_match_video_filename
if hasattr(headless_player, 'current_match_id'):
overlay_data['current_match_id'] = headless_player.current_match_id
# Add some default data if not available
if not overlay_data:
overlay_data = {
'title': 'Townships Combat League',
'subtitle': 'Live Stream',
'stream_status': 'live'
'stream_status': 'live',
'is_playing_match_video': False
}
return jsonify(overlay_data)
......
......@@ -564,18 +564,39 @@ class WebOverlayController {
if (response) {
const hasChanges = JSON.stringify(this.overlayData) !== JSON.stringify(response);
const wasPlayingMatchVideo = this.overlayData.is_playing_match_video;
const isNowPlayingMatchVideo = response.is_playing_match_video;
this.overlayData = response;
// Handle match video state changes
if (isNowPlayingMatchVideo && !wasPlayingMatchVideo) {
// Match video just started - stop rotation and load match_video template
console.log('[OverlayController] Match video started - stopping template rotation');
this.stopTemplateRotation();
this.loadTemplate('match_video');
} else if (!isNowPlayingMatchVideo && wasPlayingMatchVideo) {
// Match video just ended - restart rotation with results template first
console.log('[OverlayController] Match video ended - restarting template rotation with results');
this.loadTemplate('results');
// Restart rotation after a delay
setTimeout(() => {
this.startTemplateRotation();
}, 5000); // Show results for 5 seconds before resuming rotation
}
if (hasChanges) {
this.sendMessageToOverlay('dataUpdated', response);
}
}
// Also fetch timer state on each poll
const timerState = await this.fetchTimerState();
if (timerState && (timerState.running || this.timerState.running)) {
// Send timer update if timer is running or was running
this.sendMessageToOverlay('timerUpdate', timerState);
// Also fetch timer state on each poll (only if not playing match video)
if (!this.overlayData.is_playing_match_video) {
const timerState = await this.fetchTimerState();
if (timerState && (timerState.running || this.timerState.running)) {
// Send timer update if timer is running or was running
this.sendMessageToOverlay('timerUpdate', timerState);
}
}
return response;
......
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