I've written this simple http server to serve video file:
package main
import (
"net/http"
"os"
"bytes"
"io"
"fmt"
)
func handler(w http.ResponseWriter, r *http.Request) {
rangeValue := r.Header.Get("range")
fmt.Println("Range:")
fmt.Println(rangeValue)
buf := bytes.NewBuffer(nil)
f, _ := os.Open("oceans_1.webm")
io.Copy(buf, f) // Error handling elided for brevity.
f.Close()
w.Header().Set("Accept-Ranges","bytes")
w.Header().Set("Content-Type", "video/webm")
w.Header().Set("Content-Length","22074728")
w.Header().Set("Last-Modified", "Wed, 29 Nov 2017 17:10:44 GMT")
w.WriteHeader(206)
w.Write(buf.Bytes())
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
The video is served perfect, but I can not change time of the video. When I click on the timeline video cursor it doesn't change the position and the video doesn't jump to specific time.
When I serve the video using http.ServeFile(w, r, "oceans_1.webm")
everything works perfect - I can change video time.