I have create a static web page with golang
package main
import (
"log"
"net/http"
"html/template"
)
func ex(w http.ResponseWriter, r *http.Request) {
t, _ := template.ParseFiles("static/example.html")
t.Execute(w, nil)
}
func main() {
fs := http.FileServer(http.Dir("static"))
http.Handle("/", fs)
imagesHandler := http.FileServer(http.Dir("./video/"))
http.Handle("/video/", http.StripPrefix("/video/", imagesHandler))
http.HandleFunc("/ex", ex)
log.Println("Listening...")
http.ListenAndServe(":8080", nil)
}
example.html:
<!doctype html>
<video width="320" height="240" controls>
<source src="/video/87.mp4" type="video/mp4">
</video>
So if I go to localhost:8080/ex on my browser I can see the video playing and everything
in my react app I am doing the following (I am using import ReactPlayer from 'react-player')
render() {
return (
<ReactPlayer url='http://localhost:8080/ex' playing controls height='400'/>
)
}
The video is not working - if I change the url with a youtube video it is working fine. Could you assist me on that
Thanks