Throttle player view rebuilds after video load

This commit is contained in:
Stu 2025-12-10 05:20:37 -05:00
parent 8479bfef6f
commit feeaf8e39a

View File

@ -185,6 +185,7 @@ type appState struct {
lastSourcePath string
playerViewSource string
renderingPlayerView bool
playerViewRefreshNeeded bool
progressQuit chan struct{}
convertCancel context.CancelFunc
playerSurf *playerSurface
@ -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()
})