u
This commit is contained in:
parent
8634c204f1
commit
efe39dda4d
3
main.go
3
main.go
@ -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")
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user