u
This commit is contained in:
parent
4b107ea59f
commit
6bfd2d8736
6
main.go
6
main.go
@ -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:
|
||||||
|
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user