implamented Aroll cuter
This commit is contained in:
@@ -2,6 +2,7 @@ package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"aroll/store"
|
||||
@@ -49,6 +50,8 @@ func AnalyzeHandler(st *store.Store, hub *ws.Hub) http.HandlerFunc {
|
||||
}()
|
||||
|
||||
w.WriteHeader(http.StatusAccepted)
|
||||
|
||||
log.Println("Analyze handler works")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -34,5 +35,7 @@ func DownloadHandler(st *store.Store) http.HandlerFunc {
|
||||
fi, _ := f.Stat()
|
||||
w.Header().Set("Content-Disposition", `attachment; filename="aroll-cut.mp4"`)
|
||||
http.ServeContent(w, r, "aroll-cut.mp4", fi.ModTime(), f)
|
||||
|
||||
log.Println("Download handler works")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
@@ -57,5 +58,7 @@ func ExportHandler(st *store.Store, hub *ws.Hub) http.HandlerFunc {
|
||||
}()
|
||||
|
||||
w.WriteHeader(http.StatusAccepted)
|
||||
|
||||
log.Println("Export handler works")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
|
||||
@@ -42,5 +43,7 @@ func UploadHandler(st *store.Store) http.HandlerFunc {
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]string{"filename": key})
|
||||
|
||||
log.Println("Upload handler works")
|
||||
}
|
||||
}
|
||||
|
||||
38
handlers/zoom.go
Normal file
38
handlers/zoom.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"aroll/transcode"
|
||||
"aroll/ws"
|
||||
)
|
||||
|
||||
type zoomRequest struct {
|
||||
Zoom float64 `json:"zoom"` // 1–100, percentage of total duration to show
|
||||
Center float64 `json:"center"` // scroll center in seconds
|
||||
Duration float64 `json:"duration"` // total video duration in seconds
|
||||
}
|
||||
|
||||
func ZoomHandler(hub *ws.Hub) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
var req zoomRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
http.Error(w, "bad JSON: "+err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
h := transcode.HandlerZoom{Center: req.Center}
|
||||
result := h.TimelineZoom(req.Zoom, req.Duration)
|
||||
|
||||
data, _ := json.Marshal(result)
|
||||
hub.Broadcast(data)
|
||||
|
||||
w.WriteHeader(http.StatusAccepted)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user