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

88
main.go
View File

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