diff --git a/main.go b/main.go index a69a599..d945d46 100644 --- a/main.go +++ b/main.go @@ -38,7 +38,9 @@ func input() { os.Exit(0) case "list": 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: log.Println("unknown command") } @@ -73,10 +75,12 @@ func startWatcher() { } if event.Op&fsnotify.Create == fsnotify.Create { if utils.IsSupportedVideo(event.Name) { + log.Println("new video added:", event.Name) GlobalStreamer.Add(event.Name) } } if event.Op&fsnotify.Remove == fsnotify.Remove { + log.Println("video removed:", event.Name) GlobalStreamer.Remove(event.Name) } case err, ok := <-watcher.Errors: diff --git a/streamer/streamer.go b/streamer/streamer.go index 3613119..fab5856 100644 --- a/streamer/streamer.go +++ b/streamer/streamer.go @@ -161,6 +161,10 @@ func (s *Streamer) start() { <-s.ctx.Done() log.Printf("stop stream: %s", videoPath) + + if currentVideo == s.videoList[s.currentVideoIndex] { + s.Next() + } } func (s *Streamer) Stop() { @@ -169,7 +173,6 @@ func (s *Streamer) Stop() { go func() { done <- s.cmd.Wait() }() - s.cancel() s.mu.Lock() if s.cmd != nil && s.cmd.Process != nil {