【问题标题】:How to use jwplayer with rest query?如何将 jwplayer 与休息查询一起使用?
【发布时间】:2014-09-20 03:09:09
【问题描述】:

我正在尝试让 JWPlayer 加入我的网站。我试图从服务器获取我的视频文件。 这是我的javascript:

       <div id='player'></div>
       <script type='text/javascript'>
           jwplayer('player').setup({
               file: "http://localhost:8080/rest/course/getVideoStream",
               width: '100%',
               aspectratio: '16:9'
           });
       </script>

这里是我的休息时间:

@GET
@Path("/getVideoStream")
    @Produces("video/mp4")
public Response getVideoStream(){
    File file = new File(storagePath + "videos/courses/1.mp4");
    return Response.ok(file, "video/mp4").build();
}

它不起作用,但如果我尝试更改字段“文件”并参考包含 javascript 的文件夹中的视频,它会起作用。

【问题讨论】:

  • 不确定是否支持。我们没有对此进行测试。您有在哪里尝试过的示例吗?

标签: java javascript rest mime-types jwplayer


【解决方案1】:

如果 http://localhost:8080/rest/course/getVideoStream 确实提供有效的 mp4 文件, 尝试添加

type:'mp4'

之后

 aspectratio: '16:9'

完整代码:

   jwplayer('player').setup({
           file: "http://localhost:8080/rest/course/getVideoStream",
           width: '100%',
           aspectratio: '16:9',
           type:'mp4'
       });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-23
    • 1970-01-01
    • 1970-01-01
    • 2013-11-19
    相关资源
    最近更新 更多