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

parent eda13efa
...@@ -10699,12 +10699,21 @@ def get_overlay_data(): ...@@ -10699,12 +10699,21 @@ def get_overlay_data():
if headless_player and hasattr(headless_player, 'overlay_data'): if headless_player and hasattr(headless_player, 'overlay_data'):
overlay_data = headless_player.overlay_data.copy() if headless_player.overlay_data else {} 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 # Add some default data if not available
if not overlay_data: if not overlay_data:
overlay_data = { overlay_data = {
'title': 'Townships Combat League', 'title': 'Townships Combat League',
'subtitle': 'Live Stream', 'subtitle': 'Live Stream',
'stream_status': 'live' 'stream_status': 'live',
'is_playing_match_video': False
} }
return jsonify(overlay_data) return jsonify(overlay_data)
......
...@@ -564,19 +564,40 @@ class WebOverlayController { ...@@ -564,19 +564,40 @@ class WebOverlayController {
if (response) { if (response) {
const hasChanges = JSON.stringify(this.overlayData) !== JSON.stringify(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; 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) { if (hasChanges) {
this.sendMessageToOverlay('dataUpdated', response); this.sendMessageToOverlay('dataUpdated', response);
} }
} }
// Also fetch timer state on each poll // 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(); const timerState = await this.fetchTimerState();
if (timerState && (timerState.running || this.timerState.running)) { if (timerState && (timerState.running || this.timerState.running)) {
// Send timer update if timer is running or was running // Send timer update if timer is running or was running
this.sendMessageToOverlay('timerUpdate', timerState); this.sendMessageToOverlay('timerUpdate', timerState);
} }
}
return response; return response;
} catch (error) { } catch (error) {
......
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