ensure casting playback stops when quitting app
This commit is contained in:
+1
-1
@@ -463,7 +463,7 @@ func (a *App) Shutdown() {
|
|||||||
a.WinSMTC.Shutdown()
|
a.WinSMTC.Shutdown()
|
||||||
}
|
}
|
||||||
a.PlaybackManager.DisableCallbacks()
|
a.PlaybackManager.DisableCallbacks()
|
||||||
a.PlaybackManager.Stop() // will trigger scrobble check
|
a.PlaybackManager.Shutdown() // will trigger scrobble check
|
||||||
a.cancel()
|
a.cancel()
|
||||||
a.LocalPlayer.Destroy()
|
a.LocalPlayer.Destroy()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,10 +31,11 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type playbackCommand struct {
|
type playbackCommand struct {
|
||||||
Type playbackCommandType
|
Type playbackCommandType
|
||||||
Arg any
|
Arg any
|
||||||
Arg2 any
|
Arg2 any
|
||||||
Arg3 any
|
Arg3 any
|
||||||
|
OnDone func()
|
||||||
}
|
}
|
||||||
|
|
||||||
// playbackCommandQueue is a queue to accumulate player commands from the UI
|
// playbackCommandQueue is a queue to accumulate player commands from the UI
|
||||||
@@ -65,6 +66,13 @@ func (c *playbackCommandQueue) Stop() {
|
|||||||
playbackCommand{Type: cmdStop})
|
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() {
|
func (c *playbackCommandQueue) Continue() {
|
||||||
c.filterCommandsAndAdd([]playbackCommandType{cmdContinue, cmdPause, cmdStop},
|
c.filterCommandsAndAdd([]playbackCommandType{cmdContinue, cmdPause, cmdStop},
|
||||||
playbackCommand{Type: cmdContinue})
|
playbackCommand{Type: cmdContinue})
|
||||||
|
|||||||
@@ -512,6 +512,10 @@ func (p *PlaybackManager) Stop() {
|
|||||||
p.cmdQueue.Stop()
|
p.cmdQueue.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *PlaybackManager) Shutdown() {
|
||||||
|
p.cmdQueue.StopAndWait()
|
||||||
|
}
|
||||||
|
|
||||||
func (p *PlaybackManager) Pause() {
|
func (p *PlaybackManager) Pause() {
|
||||||
p.cmdQueue.Pause()
|
p.cmdQueue.Pause()
|
||||||
}
|
}
|
||||||
@@ -662,6 +666,9 @@ func (p *PlaybackManager) runCmdQueue(ctx context.Context) {
|
|||||||
mpv.ForceRestartPlayback()
|
mpv.ForceRestartPlayback()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if c.OnDone != nil {
|
||||||
|
c.OnDone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user