This commit is contained in:
Nite07 2024-10-24 16:23:50 +08:00
parent 8634c204f1
commit efe39dda4d
3 changed files with 19 additions and 19 deletions

View File

@ -7,6 +7,7 @@ import (
"live-streamer/server"
"live-streamer/streamer"
"live-streamer/utils"
"live-streamer/websocket"
"log"
"os"
@ -16,7 +17,7 @@ import (
var GlobalStreamer *streamer.Streamer
func main() {
server.NewServer(":8080", websocketRequestHandler)
server.NewServer(":8080", websocket.RequestHandler)
server.GlobalServer.Run()
if !utils.HasFFMPEG() {
log.Fatal("ffmpeg not found")

View File

@ -1,5 +1,10 @@
package websocket
import (
"live-streamer/streamer"
"os"
)
type RequestType string
const (
@ -18,3 +23,15 @@ type Date struct {
VideoList []string `json:"videoList"`
Output string `json:"output"`
}
func RequestHandler(reqType RequestType) {
switch reqType {
case TypeStreamNextVideo:
streamer.GlobalStreamer.Next()
case TypeStreamPrevVideo:
streamer.GlobalStreamer.Prev()
case TypeQuit:
streamer.GlobalStreamer.Close()
os.Exit(0)
}
}

View File

@ -1,18 +0,0 @@
package main
import (
"live-streamer/websocket"
"os"
)
func websocketRequestHandler(reqType websocket.RequestType) {
switch reqType {
case websocket.TypeStreamNextVideo:
GlobalStreamer.Next()
case websocket.TypeStreamPrevVideo:
GlobalStreamer.Prev()
case websocket.TypeQuit:
GlobalStreamer.Close()
os.Exit(0)
}
}