dongqian9013 2018-03-27 15:38
浏览 424

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 matlab有关常微分方程的问题求解决
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?
    • ¥100 求三轴之间相互配合画圆以及直线的算法
    • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
    • ¥15 名为“Product”的列已属于此 DataTable