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

96
main.go
View File

@ -163,44 +163,46 @@ 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
progressQuit chan struct{} playerViewSource string
convertCancel context.CancelFunc renderingPlayerView bool
playerSurf *playerSurface progressQuit chan struct{}
convertBusy bool convertCancel context.CancelFunc
convertStatus string playerSurf *playerSurface
convertActiveIn string convertBusy bool
convertActiveOut string convertStatus string
convertProgress float64 convertActiveIn string
playSess *playSession convertActiveOut string
jobQueue *queue.Queue convertProgress float64
statsBar *ui.ConversionStatsBar playSess *playSession
queueBtn *widget.Button jobQueue *queue.Queue
queueScroll *container.Scroll statsBar *ui.ConversionStatsBar
queueOffset fyne.Position queueBtn *widget.Button
compareFile1 *videoSource queueScroll *container.Scroll
compareFile2 *videoSource queueOffset fyne.Position
keyframingMode bool // Toggle for frame-accurate editing features compareFile1 *videoSource
isFullscreen bool // Fullscreen mode state compareFile2 *videoSource
keyframingMode bool // Toggle for frame-accurate editing features
isFullscreen bool // Fullscreen mode state
} }
func (s *appState) stopPreview() { 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. // showPlayerView renders the player-focused UI with a lightweight playlist.
func (s *appState) showPlayerView() { func (s *appState) showPlayerView() {
fmt.Printf("🎬 showPlayerView called\n") 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") fmt.Printf("📺 already in player view for this source; skipping rebuild\n")
return return
} }
@ -669,6 +682,7 @@ func (s *appState) showPlayerView() {
// Player area // Player area
var playerArea fyne.CanvasObject var playerArea fyne.CanvasObject
if s.source == nil { if s.source == nil {
s.playerViewSource = ""
bg := canvas.NewRectangle(utils.MustHex("#05070C")) bg := canvas.NewRectangle(utils.MustHex("#05070C"))
bg.SetMinSize(fyne.NewSize(960, 540)) bg.SetMinSize(fyne.NewSize(960, 540))
@ -718,6 +732,7 @@ func (s *appState) showPlayerView() {
s.setContent(playerArea) s.setContent(playerArea)
} else { } else {
src := s.source src := s.source
s.playerViewSource = src.Path
fmt.Printf("🎬 Creating player view for loaded video\n") fmt.Printf("🎬 Creating player view for loaded video\n")
// Image surface // Image surface
@ -4491,6 +4506,7 @@ func (s *appState) loadVideo(path string) {
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.switchToVideo(s.currentIndex) s.switchToVideo(s.currentIndex)
s.showPlayerView()
}, false) }, false)
} }
@ -4508,6 +4524,7 @@ func (s *appState) clearVideo() {
s.convert.AspectHandling = "Auto" s.convert.AspectHandling = "Auto"
s.convert.OutputAspect = "Source" s.convert.OutputAspect = "Source"
s.lastSourcePath = "" s.lastSourcePath = ""
s.playerViewSource = ""
fyne.CurrentApp().Driver().DoFromGoroutine(func() { fyne.CurrentApp().Driver().DoFromGoroutine(func() {
s.showPlayerView() s.showPlayerView()
}, false) }, false)
@ -4614,6 +4631,7 @@ func (s *appState) loadVideos(paths []string) {
s.currentIndex = 0 s.currentIndex = 0
fyne.Do(func() { fyne.Do(func() {
s.switchToVideo(0) s.switchToVideo(0)
s.showPlayerView()
}) })
}() }()
} }