implamented Aroll cuter

This commit is contained in:
2026-02-25 23:27:31 -08:00
parent 2233d08fb5
commit 0a88623264
13 changed files with 277 additions and 4 deletions

38
handlers/zoom.go Normal file
View File

@@ -0,0 +1,38 @@
package handlers
import (
"encoding/json"
"net/http"
"aroll/transcode"
"aroll/ws"
)
type zoomRequest struct {
Zoom float64 `json:"zoom"` // 1100, 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)
}
}