Guard player view render and refresh after loads

This commit is contained in:
Stu 2025-12-10 05:17:02 -05:00
parent 9d255680bf
commit 8479bfef6f

20
main.go
View File

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