From 8479bfef6fc42d0577367f614521657c524f31e8 Mon Sep 17 00:00:00 2001 From: Stu Date: Wed, 10 Dec 2025 05:17:02 -0500 Subject: [PATCH] Guard player view render and refresh after loads --- main.go | 96 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 57 insertions(+), 39 deletions(-) diff --git a/main.go b/main.go index fa9b4d0..95f25e7 100644 --- a/main.go +++ b/main.go @@ -163,44 +163,46 @@ 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 - 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 + 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() { @@ -578,7 +580,18 @@ func (s *appState) buildComparePane(src *videoSource, onStop func(), setSess fun // showPlayerView renders the player-focused UI with a lightweight playlist. func (s *appState) showPlayerView() { fmt.Printf("🎬 showPlayerView called\n") - if s.active == "player" && s.source != nil && s.lastSourcePath == s.source.Path { + if s.renderingPlayerView { + fmt.Printf("⏳ player view render already in progress, skipping\n") + return + } + s.renderingPlayerView = true + defer func() { s.renderingPlayerView = false }() + + currentPath := "" + if s.source != nil { + currentPath = s.source.Path + } + if s.active == "player" && s.source != nil && s.playerViewSource == currentPath { fmt.Printf("📺 already in player view for this source; skipping rebuild\n") return } @@ -669,6 +682,7 @@ func (s *appState) showPlayerView() { // Player area var playerArea fyne.CanvasObject if s.source == nil { + s.playerViewSource = "" bg := canvas.NewRectangle(utils.MustHex("#05070C")) bg.SetMinSize(fyne.NewSize(960, 540)) @@ -718,6 +732,7 @@ func (s *appState) showPlayerView() { s.setContent(playerArea) } else { src := s.source + s.playerViewSource = src.Path fmt.Printf("🎬 Creating player view for loaded video\n") // Image surface @@ -4491,6 +4506,7 @@ func (s *appState) loadVideo(path string) { fmt.Printf("🔄 Switching to player view...\n") fyne.CurrentApp().Driver().DoFromGoroutine(func() { s.switchToVideo(s.currentIndex) + s.showPlayerView() }, false) } @@ -4508,6 +4524,7 @@ func (s *appState) clearVideo() { s.convert.AspectHandling = "Auto" s.convert.OutputAspect = "Source" s.lastSourcePath = "" + s.playerViewSource = "" fyne.CurrentApp().Driver().DoFromGoroutine(func() { s.showPlayerView() }, false) @@ -4614,6 +4631,7 @@ func (s *appState) loadVideos(paths []string) { s.currentIndex = 0 fyne.Do(func() { s.switchToVideo(0) + s.showPlayerView() }) }() }