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?