Clear player session on video reset

This commit is contained in:
Stu Leak 2026-01-10 02:46:10 -05:00
parent 9afe4251df
commit 3d7cbfa22e

27
main.go
View File

@ -11528,6 +11528,22 @@ func (p *playSession) Stop() {
p.stopLocked()
}
func (p *playSession) Close() {
p.mu.Lock()
defer p.mu.Unlock()
p.stopLocked()
if p.gstPlayer != nil {
p.gstPlayer.Close()
p.gstPlayer = nil
}
if p.img != nil {
p.img.Resource = nil
p.img.File = ""
p.img.Image = nil
}
}
func (p *playSession) stopLocked() {
// Stop GStreamer player
if p.gstPlayer != nil {
@ -12660,6 +12676,7 @@ func (s *appState) loadMultipleVideos(paths []string) {
func (s *appState) clearVideo() {
logging.Debug(logging.CatModule, "clearing loaded video")
s.releasePlaybackSession()
s.stopPlayer()
s.source = nil
s.loadedVideos = nil
@ -12676,6 +12693,14 @@ func (s *appState) clearVideo() {
}, false)
}
func (s *appState) releasePlaybackSession() {
s.stopPreview()
if s.playSess != nil {
s.playSess.Close()
s.playSess = nil
}
}
// loadVideos loads multiple videos for navigation
func (s *appState) loadVideos(paths []string) {
if len(paths) == 0 {
@ -15362,6 +15387,8 @@ func buildPlayerView(state *appState) fyne.CanvasObject {
// Clear video button
clearBtn := widget.NewButton("Clear Video", func() {
state.releasePlaybackSession()
state.stopPlayer()
state.playerFile = nil
state.showPlayerView()
})