Avoid player view rebuild when already active

This commit is contained in:
Stu 2025-12-10 03:13:54 -05:00
parent ee08618142
commit fc1e91bda6

51
main.go
View File

@ -266,19 +266,7 @@ func (s *appState) queueProgressCounts() (completed, total int) {
}
func (s *appState) updateQueueButtonLabel() {
if s.queueBtn == nil {
return
}
completed, total := s.queueProgressCounts()
// Include active direct conversion in totals
if s.convertBusy {
total++
}
label := "View Queue"
if total > 0 {
label = fmt.Sprintf("View Queue %d/%d", completed, total)
}
s.queueBtn.SetText(label)
// Queue UI hidden in player-only mode.
}
type playerSurface struct {
@ -431,6 +419,16 @@ func (s *appState) showMainMenu() {
s.showPlayerView()
}
func (s *appState) onClose() {
s.stopPreview()
s.stopPlayer()
s.stopCompareSessions()
if s.jobQueue != nil {
s.jobQueue.Stop()
}
logging.Close()
}
// showCompareView renders a simple side-by-side player for the first two loaded videos.
func (s *appState) showCompareView() {
s.stopPreview()
@ -579,6 +577,10 @@ 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.playSess != nil {
fmt.Printf("📺 already in player view; skipping rebuild\n")
return
}
s.stopPreview()
s.stopPlayer()
s.stopCompareSessions()
@ -1987,6 +1989,10 @@ func runGUI() {
a.Settings().SetTheme(&ui.MonoTheme{})
logging.Debug(logging.CatUI, "created fyne app: %#v", a)
w := a.NewWindow("VT Player")
w.SetOnClosed(func() {
state.onClose()
a.Quit()
})
if icon := utils.LoadAppIcon(); icon != nil {
a.SetIcon(icon)
w.SetIcon(icon)
@ -2048,7 +2054,7 @@ func runGUI() {
// Initialize conversion stats bar
state.statsBar = ui.NewConversionStatsBar(func() {
// Clicking the stats bar opens the queue view
state.showQueue()
// Queue hidden in player-only mode
})
// Initialize job queue
@ -2061,9 +2067,6 @@ func runGUI() {
app.Driver().DoFromGoroutine(func() {
state.updateStatsBar()
state.updateQueueButtonLabel()
if state.active == "queue" {
state.refreshQueueView()
}
}, false)
})
@ -2100,19 +2103,7 @@ func runGUI() {
fmt.Printf("✅ showMainMenu completed\n")
logging.Debug(logging.CatUI, "main menu rendered with %d modules", len(modulesList))
// Start stats bar update loop on a timer
go func() {
ticker := time.NewTicker(500 * time.Millisecond)
defer ticker.Stop()
for range ticker.C {
app := fyne.CurrentApp()
if app != nil && app.Driver() != nil {
app.Driver().DoFromGoroutine(func() {
state.updateStatsBar()
}, false)
}
}
}()
// Stats update loop disabled in player-only mode to avoid view churn.
w.ShowAndRun()
}