我有一个用于播放mp4视频的servlet
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");
}
我有一个用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>
视频播放没有问题,但是当我按重播时它不会重播视频甚至再次调用Servlet。相反,它只是继续显示加载图标,这里有什么问题?请帮帮我