为RequestMapping提供范围标题支持

时间:2015-03-18 12:36:48

标签: java http video-streaming

我有加密的视频文件,它们被解密并通过响应输出流发送。代码是:

@RequestMapping(value = { "/getmedia" }, method = RequestMethod.GET)
    public void getmedia(Model model, HttpServletRequest request, HttpServletResponse response) {
    String filepath = request.getParameter("f");
    File sourceFile = new File(filepath);
    os = AESHelper.decryptAsdecompress(sourceFile, Key);
    baos = new ByteArrayOutputStream();
    baos = (ByteArrayOutputStream) os;

    byte[] imageBytes = baos.toByteArray();
    response.setContentType("video/mp4");
    response.setContentLength(imageBytes.length);
    response.getOutputStream().write(imageBytes);
    response.getOutputStream().flush();
}

我在Chrome浏览器中看到视频时遇到问题,当按下第一次播放视频播放时。但是第二次没有播放。(播放器中的黑屏)。在开发人员工具中,我看到第一次Range标题为:Range: bytes=0-,第二次是Range: bytes=44012-12147544

在视图中我正在使用视频标记:

<video id="jp_video_0" style="width: 800px; height: 500px;" src="http://localhost:8080/Web/media/getmedia?f=1_d3&e=mp4" type="video/mp4"></video>

如何为此RequestMapping提供范围标题支持?

0 个答案:

没有答案
相关问题