add video lifecycle controls
This commit is contained in:
+63
-13
@@ -385,6 +385,7 @@ func main() {
|
|||||||
audioStr string = args.AudioFlowId
|
audioStr string = args.AudioFlowId
|
||||||
showStats bool = true
|
showStats bool = true
|
||||||
)
|
)
|
||||||
|
videoActive := useVideoSlot
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@@ -481,22 +482,32 @@ func main() {
|
|||||||
return fmt.Errorf("reopen: no flow specified")
|
return fmt.Errorf("reopen: no flow specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enqueueVideoConfig := func(config playback.FeedConfig) {
|
||||||
|
select {
|
||||||
|
case <-videoCommands:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
case videoCommands <- config:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
doReconnect := func() {
|
doReconnect := func() {
|
||||||
if useVideoSlot {
|
if useVideoSlot {
|
||||||
config := playback.FeedConfig{
|
videoActive = videoStr != ""
|
||||||
Domain: domainStr,
|
|
||||||
UUID: videoStr,
|
config := playback.FeedConfig{}
|
||||||
Active: videoStr != "",
|
if videoStr != "" {
|
||||||
}
|
config = playback.FeedConfig{
|
||||||
// GUI is the only sender. Replace an older pending command
|
Domain: domainStr,
|
||||||
select {
|
UUID: videoStr,
|
||||||
case <-videoCommands:
|
Active: true,
|
||||||
default:
|
}
|
||||||
}
|
|
||||||
select {
|
|
||||||
case videoCommands <- config:
|
|
||||||
default:
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enqueueVideoConfig(config)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
@@ -848,6 +859,45 @@ func main() {
|
|||||||
if cimgui.Button("Connect") {
|
if cimgui.Button("Connect") {
|
||||||
doReconnect()
|
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()
|
cimgui.End()
|
||||||
gui.EndFrame()
|
gui.EndFrame()
|
||||||
lastFrame = time.Now()
|
lastFrame = time.Now()
|
||||||
|
|||||||
Reference in New Issue
Block a user