i have a servlet which streams an mp4 video
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
File file = new File("D:\\Software\\apache-tomcat-7.0.57\\apache-tomcat-7.0.57\\bin\\vid\\testMp4.mp4");
response.setContentType("video/mp4");
response.setHeader("Content-Disposition",
"attachment;filename=" + file.getName());
ServletContext ctx = getServletContext();
FileInputStream is = new FileInputStream(file);
int read = 0;
byte[] bytes = new byte[320652];
OutputStream os = response.getOutputStream();
while ((read = is.read(bytes)) != -1) {
os.write(bytes, 0, read);
}
os.flush();
os.close();
System.out.println("file sent");
}
and i have a a page to play this video with JW Player
<script>
//alert(window.location.pathname);
//alert(window.location.);
jwplayer("mediaplayer").setup({
width: 520,
height: 440,
type:'mp4',
file: 'http://localhost:8080/WorldCupWeb/getVid',
tracks: [{
file: 'http://localhost:8080/WorldCupWeb/getVid' + '.vtt',
kind: 'thumbnails'
}]
});
</script>
The video plays without a problem , but when i press replay it wont replay the video or even call the Servlet again. instead it just keep showing the loading icon , what is wrong here ? help me please