From 1571e2700c470eb7f2ce0f785372f3b663fc6837 Mon Sep 17 00:00:00 2001 From: Dmitry Sergeev Date: Thu, 27 Aug 2026 21:59:11 +0300 Subject: [PATCH] add video lifecycle controls --- cmd/mxl-player/main.go | 76 ++++++++++++++++++++++++++++++++++-------- imgui.ini | 4 +-- 2 files changed, 65 insertions(+), 15 deletions(-) diff --git a/cmd/mxl-player/main.go b/cmd/mxl-player/main.go index 63ca4b5..ca405ed 100644 --- a/cmd/mxl-player/main.go +++ b/cmd/mxl-player/main.go @@ -385,6 +385,7 @@ func main() { audioStr string = args.AudioFlowId showStats bool = true ) + videoActive := useVideoSlot ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -481,22 +482,32 @@ func main() { return fmt.Errorf("reopen: no flow specified") } + enqueueVideoConfig := func(config playback.FeedConfig) { + select { + case <-videoCommands: + default: + } + + select { + case videoCommands <- config: + default: + } + } + doReconnect := func() { if useVideoSlot { - config := playback.FeedConfig{ - Domain: domainStr, - UUID: videoStr, - Active: videoStr != "", - } - // GUI is the only sender. Replace an older pending command - select { - case <-videoCommands: - default: - } - select { - case videoCommands <- config: - default: + videoActive = videoStr != "" + + config := playback.FeedConfig{} + if videoStr != "" { + config = playback.FeedConfig{ + Domain: domainStr, + UUID: videoStr, + Active: true, + } } + + enqueueVideoConfig(config) return } select { @@ -848,6 +859,45 @@ func main() { if cimgui.Button("Connect") { doReconnect() } + if useVideoSlot && videoActive { + cimgui.SameLine() + if cimgui.Button("Stop video") { + videoActive = false + enqueueVideoConfig( + playback.FeedConfig{ + Domain: domainStr, + UUID: videoStr, + Active: false, + }) + } + } + if useVideoSlot && !videoActive && videoStr != "" { + cimgui.SameLine() + if cimgui.Button("Resume video") { + videoActive = true + enqueueVideoConfig(playback.FeedConfig{ + Domain: domainStr, + UUID: videoStr, + Active: true, + }) + } + } + if useVideoSlot && videoStr != "" { + if cimgui.Button("Remove video") { + videoActive = false + videoStr = "" + enqueueVideoConfig(playback.FeedConfig{}) + } + } + if useVideoSlot { + if videoActive { + cimgui.Text("Video state: active") + } else if videoStr != "" { + cimgui.Text("Video state: stopped") + } else { + cimgui.Text("Video state: not configured") + } + } cimgui.End() gui.EndFrame() lastFrame = time.Now() diff --git a/imgui.ini b/imgui.ini index 1332414..9730e1b 100644 --- a/imgui.ini +++ b/imgui.ini @@ -14,7 +14,7 @@ Size=200,200 Collapsed=0 [Window][Connection] -Pos=388,158 -Size=523,141 +Pos=421,219 +Size=518,191 Collapsed=0