fix: front-end not save token

fix: sometimes not auto stream next video
This commit is contained in:
2024-10-28 15:52:02 +08:00
parent dcdbf84c8c
commit 369b658d60
2 changed files with 26 additions and 6 deletions

View File

@@ -129,8 +129,14 @@ func (s *Streamer) handleStart() {
s.writeOutput(fmt.Sprintf("stop stream: %s\n", videoPath))
if !s.state.manualControl {
s.mailbox <- NextVideoMessage{}
log.Println("ready to stream next video")
s.state.currentVideoIndex++
if s.state.currentVideoIndex >= len(s.state.videoList) {
s.state.currentVideoIndex = 0
}
s.mailbox <- StartMessage{}
} else {
log.Println("manually control")
s.state.manualControl = false
}
@@ -143,15 +149,22 @@ func (s *Streamer) handleStop() {
return
}
log.Println("wait context to be cancelled")
s.state.cancel()
log.Println("context has been cancelled")
if s.state.cmd.Process != nil {
log.Println("wait ffmpeg process stop")
select {
case <-s.state.waitDone:
case <-time.After(3 * time.Second):
_ = s.state.cmd.Process.Kill()
}
log.Println("ffmpeg process has stopped")
}
s.state.cancel = nil
s.state.cmd = nil
}
func (s *Streamer) handleAdd(path string) {