ensure casting playback stops when quitting app

This commit is contained in:
Drew Weymouth
2025-03-29 15:15:13 -07:00
parent ff455528d6
commit 6a7f06769d
3 changed files with 20 additions and 5 deletions
+12 -4
View File
@@ -31,10 +31,11 @@ const (
)
type playbackCommand struct {
Type playbackCommandType
Arg any
Arg2 any
Arg3 any
Type playbackCommandType
Arg any
Arg2 any
Arg3 any
OnDone func()
}
// playbackCommandQueue is a queue to accumulate player commands from the UI
@@ -65,6 +66,13 @@ func (c *playbackCommandQueue) Stop() {
playbackCommand{Type: cmdStop})
}
func (c *playbackCommandQueue) StopAndWait() {
done := make(chan struct{})
c.filterCommandsAndAdd([]playbackCommandType{cmdContinue, cmdPause, cmdStop},
playbackCommand{Type: cmdStop, OnDone: func() { close(done) }})
<-done
}
func (c *playbackCommandQueue) Continue() {
c.filterCommandsAndAdd([]playbackCommandType{cmdContinue, cmdPause, cmdStop},
playbackCommand{Type: cmdContinue})