【发布时间】:2017-12-28 10:49:20
【问题描述】:
我想从 mongodb 获取视频而不是它应该播放该视频的视频大小,但它只播放几秒钟,我给 maxUploadSize 是 20mb 和 maxInMemorySize 也是 20mb,但在 jsp 页面上,它甚至只获取 1mb 视频视频大小超过 1mb。 我不知道该怎么做,视频应该根据视频大小播放完整
这里是控制器
@RequestMapping(value = "/welcome-video-controller/{videoObj}", produces = "video/webm")
@ResponseBody
public ResponseEntity<byte[]> getVideoForLoginPage(@PathVariable String videoObj, HttpServletResponse response)
throws IOException {
LOG.info("Entry :: getVideoForPost");
BufferedImage bufferedVideoForPost = null;
URL resourcePath = null;
byte[] videoArray = null;
ResponseEntity<byte[]> result = null;
LOG.info("videoObj-->" + videoObj);
File videoFromMongo = new File(VIDEO_FROM_PATH + videoObj);
GridFSDBFile videoFile = MongoUtility.getVideoFileFromMongo(videoObj);
videoFile.writeTo(videoFromMongo);
bufferedVideoForPost = ImageIO.read(videoFromMongo);
videoFile.getInputStream();
HttpHeaders headers = new HttpHeaders();
headers.setContentLength((int) videoFile.getLength());
videoArray = new byte[(int) videoFile.getLength()];
result = new ResponseEntity<byte[]>(videoArray, headers, HttpStatus.OK);
videoFile.getInputStream().read(videoArray);
LOG.info("videoArray-->" + videoArray);
LOG.info("videoArray size-->" + videoArray.length);
return result;
}
这是 html 编码
<c:set value="${videoPostDetail.videoNames}" var="videoObj" />
<c:if test="${videoObj ne ''}">
<video width="96%" height="220" controls id="sideVideo">
<source src='/SocialNetworkingApp/welcome-video-controller/${videoObj}.do' type='video/webm'>
</video>
</c:if>
它应该播放完整的视频,我尝试了很多但没有任何效果,请告诉什么问题,
【问题讨论】:
标签: spring mongodb spring-mvc html5-video