From feeaf8e39a15cc15e8c1805c5a24520e9c41c1fa Mon Sep 17 00:00:00 2001 From: Stu Date: Wed, 10 Dec 2025 05:20:37 -0500 Subject: [PATCH] Throttle player view rebuilds after video load --- main.go | 88 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 41 deletions(-) diff --git a/main.go b/main.go index 95f25e7..ed64f14 100644 --- a/main.go +++ b/main.go @@ -163,46 +163,47 @@ func (c convertConfig) CoverLabel() string { } type appState struct { - window fyne.Window - active string - lastModule string - source *videoSource - loadedVideos []*videoSource // Multiple loaded videos for navigation - currentIndex int // Current video index in loadedVideos - anim *previewAnimator - convert convertConfig - currentFrame string - player player.Controller - playerReady bool - playerVolume float64 - playerMuted bool - lastVolume float64 - playerPaused bool - playerPos float64 - playerLast time.Time - compareSess1 *playSession - compareSess2 *playSession - lastSourcePath string - playerViewSource string - renderingPlayerView bool - progressQuit chan struct{} - convertCancel context.CancelFunc - playerSurf *playerSurface - convertBusy bool - convertStatus string - convertActiveIn string - convertActiveOut string - convertProgress float64 - playSess *playSession - jobQueue *queue.Queue - statsBar *ui.ConversionStatsBar - queueBtn *widget.Button - queueScroll *container.Scroll - queueOffset fyne.Position - compareFile1 *videoSource - compareFile2 *videoSource - keyframingMode bool // Toggle for frame-accurate editing features - isFullscreen bool // Fullscreen mode state + window fyne.Window + active string + lastModule string + source *videoSource + loadedVideos []*videoSource // Multiple loaded videos for navigation + currentIndex int // Current video index in loadedVideos + anim *previewAnimator + convert convertConfig + currentFrame string + player player.Controller + playerReady bool + playerVolume float64 + playerMuted bool + lastVolume float64 + playerPaused bool + playerPos float64 + playerLast time.Time + compareSess1 *playSession + compareSess2 *playSession + lastSourcePath string + playerViewSource string + renderingPlayerView bool + playerViewRefreshNeeded bool + progressQuit chan struct{} + convertCancel context.CancelFunc + playerSurf *playerSurface + convertBusy bool + convertStatus string + convertActiveIn string + convertActiveOut string + convertProgress float64 + playSess *playSession + jobQueue *queue.Queue + statsBar *ui.ConversionStatsBar + queueBtn *widget.Button + queueScroll *container.Scroll + queueOffset fyne.Position + compareFile1 *videoSource + compareFile2 *videoSource + keyframingMode bool // Toggle for frame-accurate editing features + isFullscreen bool // Fullscreen mode state } func (s *appState) stopPreview() { @@ -419,6 +420,7 @@ func (s *appState) showErrorWithCopy(title string, err error) { func (s *appState) showMainMenu() { fmt.Printf("🎬 showMainMenu called - going to player view\n") // Minimal entry point: go straight to the player view. + s.playerViewRefreshNeeded = true s.showPlayerView() } @@ -591,10 +593,11 @@ func (s *appState) showPlayerView() { if s.source != nil { currentPath = s.source.Path } - if s.active == "player" && s.source != nil && s.playerViewSource == currentPath { + if !s.playerViewRefreshNeeded && s.active == "player" && s.source != nil && s.playerViewSource == currentPath { fmt.Printf("📺 already in player view for this source; skipping rebuild\n") return } + s.playerViewRefreshNeeded = false // Do not stop the player; only clear compare previews. s.stopCompareSessions() s.active = "player" @@ -4505,6 +4508,7 @@ func (s *appState) loadVideo(path string) { logging.Debug(logging.CatModule, "video loaded %+v", src) fmt.Printf("🔄 Switching to player view...\n") fyne.CurrentApp().Driver().DoFromGoroutine(func() { + s.playerViewRefreshNeeded = true s.switchToVideo(s.currentIndex) s.showPlayerView() }, false) @@ -4525,6 +4529,7 @@ func (s *appState) clearVideo() { s.convert.OutputAspect = "Source" s.lastSourcePath = "" s.playerViewSource = "" + s.playerViewRefreshNeeded = true fyne.CurrentApp().Driver().DoFromGoroutine(func() { s.showPlayerView() }, false) @@ -4630,6 +4635,7 @@ func (s *appState) loadVideos(paths []string) { s.loadedVideos = loaded s.currentIndex = 0 fyne.Do(func() { + s.playerViewRefreshNeeded = true s.switchToVideo(0) s.showPlayerView() })