Sync lyrics highlighting with playback progress
This pull request introduces enhancements to playback state management and lyrics synchronization within the psst-gui application. Key changes include the addition of playback state tracking in the CommonCtx, a new LyricsTicker controller for real-time updates, and improvements to the lyrics widget for dynamic synchronization with playback progress.
Playback State Management Enhancements:
psst-gui/src/data/mod.rs: Addedprogress,last_update_ms, andplayback_statefields toCommonCtxfor tracking playback progress and state. Introduced a helper methodset_common_progressto update progress and timestamp consistently. [1] [2] [3]
Lyrics Synchronization Improvements:
psst-gui/src/ui/lyrics.rs: Added aLyricsTickercontroller for periodic updates to the lyrics widget, ensuring synchronization with playback progress. [1] [2]psst-gui/src/ui/lyrics.rs: Enhanced the lyrics widget to dynamically highlight lyrics based on playback progress, using calculated offsets and playback state. [1] [2]
These changes improve the user experience by providing accurate playback state tracking and seamless lyrics synchronization during music playback.
close https://github.com/jpochyla/psst/issues/658
This looks great! One think I was wondering is if your explored tracking the playback state (elapsed time) from the same tracker that is used as the reference for the seek bar UI? It would be nice if we had a single global tracking implementation that the lyrics could then just tie into.
I tried to implement it with the tracking already in place, but I couldn't. It lacks precision on the timer update. It lacks precision on the timer update, which creates a visible discrepancy between speech and sound. I couldn't find any other way but to make my own timer faster, but I admit it's not the best solution.
I think my last commit has a better management of timer
This looks a lot better in the last commit. However, and I'm not so familiar with the report precision. It might be interesting if the CPU cycles are greater with this PR. Maybe if you're interested, could you check to make sure this doesn't use a lot more CPU by increasing the timing precision?