Feature/music skip delay (#115)

* feat: Add configurable delay for music module skip when nothing playing

- Add 'skip_when_nothing_playing' and 'skip_delay_seconds' config options
- Implement timer-based skip logic that waits 2 seconds before skipping
- Reset timer when music resumes or display is deactivated
- Improve user experience by preventing jarring immediate skips
- Maintains backward compatibility with existing configurations

* feat: Add live priority support to music manager

- Add 'live_priority' and 'live_game_duration' config options for music
- Integrate music manager into live priority rotation system
- Add 'music_live' mode that participates in live priority takeover
- Music manager joins live priority rotation when actively playing
- Supports future plugin ecosystem with consistent live priority interface
- Maintains backward compatibility with existing music configurations

* feat: Add new music settings to web interface

- Add 'Skip When Nothing Playing' checkbox and delay configuration
- Add 'Enable Live Priority' checkbox and duration configuration
- Update music form JavaScript to save all new settings
- Users can now configure music skip behavior and live priority through web UI

* fix: Improve music live priority integration

- Enhanced music live content detection with detailed logging
- Modified live priority logic to properly handle music mode
- Added music to live priority sports collection when actively playing
- Updated live priority rotation to handle music mode correctly
- Improved live priority takeover logic for music manager
- Music now properly participates in live priority rotation when playing

* perf: Reduce logging frequency for music live priority

- Add timestamp-based throttling to music live priority logging
- Info messages now only appear every 30 seconds instead of every few milliseconds
- Debug messages are also throttled to reduce log spam
- Maintains visibility of important events while reducing noise

* Fix unreachable code bug in music live priority handling

- Moved music live priority logic outside the sports iteration loop where it was unreachable
- The 'if sport == music' block was never executed since 'music' wasn't in the sports list
- Consolidated music handling in its own separate section for cleaner code structure
- Added music configuration options to config template
- Maintained exact same functionality while eliminating dead code

* Fix music_live_game_duration setting not being used

- Modified get_current_duration() method to check for music live priority mode
- When music is in live priority mode, use configured live_game_duration setting
- Added proper config reading for music_live_game_duration during initialization
- Ensures music displays for the configured duration when in live priority mode

* Fix stale timestamp bug in live priority debug logging

- Fixed issue where debug log at line 1240 was using a stale current_time variable
- The current_time variable was conditionally reassigned in music live priority check
- This caused inconsistent log throttling behavior
- Now uses fresh current_time_for_debug variable for accurate throttling
This commit is contained in:
Chuck
2025-10-16 16:46:37 -04:00
committed by GitHub
parent 9c313cdac3
commit ce79ccaec2
4 changed files with 223 additions and 40 deletions

View File

@@ -1790,6 +1790,37 @@
<input type="number" class="form-control" id="music_polling_interval" name="music_polling_interval" value="{{ safe_config_get(main_config, 'music', 'POLLING_INTERVAL_SECONDS', default=1) }}" min="1" max="60">
<div class="description">How often to check for music updates</div>
</div>
<div class="form-row">
<div class="form-group">
<label>
<input type="checkbox" id="music_skip_when_nothing_playing" name="music_skip_when_nothing_playing" {% if safe_config_get(main_config, 'music', 'skip_when_nothing_playing', default=True) %}checked{% endif %}>
Skip When Nothing Playing
</label>
<div class="description">Skip to next module when no music is playing</div>
</div>
<div class="form-group">
<label for="music_skip_delay_seconds">Skip Delay (seconds):</label>
<input type="number" class="form-control" id="music_skip_delay_seconds" name="music_skip_delay_seconds" value="{{ safe_config_get(main_config, 'music', 'skip_delay_seconds', default=2) }}" min="0" max="60">
<div class="description">Wait time before skipping when nothing playing</div>
</div>
</div>
<div class="form-row">
<div class="form-group">
<label>
<input type="checkbox" id="music_live_priority" name="music_live_priority" {% if safe_config_get(main_config, 'music', 'live_priority', default=True) %}checked{% endif %}>
Enable Live Priority
</label>
<div class="description">Include music in live priority rotation when playing</div>
</div>
<div class="form-group">
<label for="music_live_game_duration">Live Duration (seconds):</label>
<input type="number" class="form-control" id="music_live_game_duration" name="music_live_game_duration" value="{{ safe_config_get(main_config, 'music', 'live_game_duration', default=30) }}" min="10" max="300">
<div class="description">How long music stays in live priority rotation</div>
</div>
</div>
<button type="submit" class="btn btn-success">Save Music Settings</button>
</form>
</div>
@@ -3222,7 +3253,11 @@
enabled: document.getElementById('music_enabled').checked,
preferred_source: document.getElementById('music_preferred_source').value,
YTM_COMPANION_URL: document.getElementById('ytm_companion_url').value,
POLLING_INTERVAL_SECONDS: parseInt(document.getElementById('music_polling_interval').value)
POLLING_INTERVAL_SECONDS: parseInt(document.getElementById('music_polling_interval').value),
skip_when_nothing_playing: document.getElementById('music_skip_when_nothing_playing').checked,
skip_delay_seconds: parseInt(document.getElementById('music_skip_delay_seconds').value),
live_priority: document.getElementById('music_live_priority').checked,
live_game_duration: parseInt(document.getElementById('music_live_game_duration').value)
}
};
await saveConfigJson(payload);