react-player没有播放html的<video>标签

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

dontoften8899
dontoften8899 谢谢,所以我做了,现在它的工作状况如下:将<ReactPlayerurl='localhost:8080/ex'的播放控件height='400'/>更改为<ReactPlayerurl='localhost:8080/video/87.mp4'播放控件height='400'/>
2 年多之前 回复
doudou0612
doudou0612 好像您正在将HTML页面传递给url参数,而不是视频URL。您不应该传递url='/video/87.mp4'吗?
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐