1

I have encrypted video files, which are decrypted and send through response output stream. code is:

@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();
}

I am facing problem to see video in chrome browser, when press play for first time video get played. but at second time nothing get played.(black screen in player). In developer tools I have seen that for first time Range header is : Range: bytes=0- and at the second time it's Range: bytes=44012-12147544.

On view I am using video tag :

<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>

How to give range header support to this RequestMapping?

Amogh
  • 4,453
  • 11
  • 45
  • 106
  • Check out the answer here -- http://stackoverflow.com/questions/20634603/how-do-i-return-a-video-with-spring-mvc-so-that-it-can-be-navigated-using-the-ht – Gyan Mar 18 '15 at 12:50
  • @Gyanapriya I don't think HTTP resume support could help me. because I have to decrypt the file and send through output stream. In video tag I am using url like `http://localhost:8080Web/media/getmedia?f=1_d3&e=mp4`. I don't need rewinding, fast forward, navigating – Amogh Mar 18 '15 at 12:52
  • @Gyanapriya can do something so that chrome don't send Range header. because this request mapping is working fine in IE and Firefox – Amogh Mar 18 '15 at 12:59
  • can you reset the Range header if the video ended and the button is pushed? – Zorian Mar 18 '15 at 13:02
  • @Zorian actually whole day I was finding for the same but didn't find or succeeded in that. I checked `mod_headers` but didn't come to how to enable in Tomcat7 used in sts. If you could help than It will be so helpful – Amogh Mar 18 '15 at 13:05
  • sry but I can't help you, it was just an idea, I thought was worth to mention, but I'm still learning java and are not that good. But your topic is interesting and I hope you will find a solution quickly – Zorian Mar 18 '15 at 13:08

0 Answers0