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

View File

@ -1,5 +1,10 @@
package websocket package websocket
import (
"live-streamer/streamer"
"os"
)
type RequestType string type RequestType string
const ( const (
@ -18,3 +23,15 @@ type Date struct {
VideoList []string `json:"videoList"` VideoList []string `json:"videoList"`
Output string `json:"output"` 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)
}
}