This commit is contained in:
Nite07 2024-10-23 17:08:05 +08:00
parent 4b107ea59f
commit 6bfd2d8736
2 changed files with 9 additions and 2 deletions

View File

@ -38,7 +38,9 @@ func input() {
os.Exit(0) os.Exit(0)
case "list": case "list":
list := GlobalStreamer.GetVideoListPath() list := GlobalStreamer.GetVideoListPath()
log.Println(strings.Join(list, "\n")) log.Println("\nvideo list:\n", strings.Join(list, "\n"))
case "current":
log.Println("current video: ", GlobalStreamer.GetCurrentVideo())
default: default:
log.Println("unknown command") log.Println("unknown command")
} }
@ -73,10 +75,12 @@ func startWatcher() {
} }
if event.Op&fsnotify.Create == fsnotify.Create { if event.Op&fsnotify.Create == fsnotify.Create {
if utils.IsSupportedVideo(event.Name) { if utils.IsSupportedVideo(event.Name) {
log.Println("new video added:", event.Name)
GlobalStreamer.Add(event.Name) GlobalStreamer.Add(event.Name)
} }
} }
if event.Op&fsnotify.Remove == fsnotify.Remove { if event.Op&fsnotify.Remove == fsnotify.Remove {
log.Println("video removed:", event.Name)
GlobalStreamer.Remove(event.Name) GlobalStreamer.Remove(event.Name)
} }
case err, ok := <-watcher.Errors: case err, ok := <-watcher.Errors:

View File

@ -161,6 +161,10 @@ func (s *Streamer) start() {
<-s.ctx.Done() <-s.ctx.Done()
log.Printf("stop stream: %s", videoPath) log.Printf("stop stream: %s", videoPath)
if currentVideo == s.videoList[s.currentVideoIndex] {
s.Next()
}
} }
func (s *Streamer) Stop() { func (s *Streamer) Stop() {
@ -169,7 +173,6 @@ func (s *Streamer) Stop() {
go func() { go func() {
done <- s.cmd.Wait() done <- s.cmd.Wait()
}() }()
s.cancel() s.cancel()
s.mu.Lock() s.mu.Lock()
if s.cmd != nil && s.cmd.Process != nil { if s.cmd != nil && s.cmd.Process != nil {