Streaming video in play framework using videojs

2019-04-17 08:00发布

Recently I have been working with my friend on a web application in play framework 1.2.4 where we were trying to stream a video stored in the /public directory of the project using the videojs player. This video was in .mp4 format but I guess this is irrelevant for this question. We were accessing the video directly without using any server side scripts. We have spotted 2 issues the arose during our tests.

  1. The video was never buffered all the way to the end. Only a few seconds ahead were always stored in the buffer.

  2. When playing the video, if we pressed pause and then play, the playback of the video would break completely. Sometimes it would be buffering the video forever, other times it would look like it continues with the playback of the video, but it would only show a black screen and no sound.

When we tried the same videojs script on the files stored not in the web application, but served from some other servers it worked flawlessly. Even if the other server was just tomcat running on the same computer. Therefore, I suggest this must be an issue with the server play uses to run its applications. We were running the application using the "play run" command and with the default configurations. Can anyone explain this strange behaviour? Is there something that needs to be set in the configurations, or is this just a bug? Thanks.

1条回答
迷人小祖宗
2楼-- · 2019-04-17 08:39

I think thats a problem with the range support in netty / the play controller handling public folder. ( http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35 )

You should be able to test this with curl.. e.g. like described in this post http://linuxandfriends.com/2008/11/01/curl-split-a-file-and-download-simultaneously-from-multiple-locations/

However, in production, you're usually fronting play with lighttpd/nginx (to allow to bind port 80) so the files from the public folder get served by something other than play... you shouldn't have a problem then.

查看更多
登录 后发表回答