react-player不从html播放<video>标签

时间:2018-03-27 15:38:34

标签: html reactjs go video

我用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>

所以,如果我在浏览器上访问localhost:8080 / ex,我可以看到视频播放和所有内容

在我的反应应用程序中我正在执行以下操作(我使用来自'react-player'的导入ReactPlayer)

render() {
        return (
            <ReactPlayer url='http://localhost:8080/ex' playing controls height='400'/>
        )
    }

视频无效 - 如果我使用youtube视频更改网址,则表示正常。你能帮助我吗

由于

0 个答案:

没有答案