我想从我的本地目录(" E:\ video")加载视频文件,并在我的Spring MVC Web应用程序中使用JW Player显示它。 JW播放器不播放视频文件,只显示加载图标。
我的前端播放器设置:
$(function() {
var vplayer = jwplayer("playerDiv").setup({
'flashplayer': '../../player.swf',
'id': 'playerID',
'width': '440',
'height': '380',
'mute': false,
'volume': '100',
'file': 'spring/loadVideoFile',
'controlbar': 'bottom',
'provider': 'video'
});
vplayer.play();
});
我的请求处理程序:
@RequestMapping(value = "/loadVideoFile", method = RequestMethod.GET)
@ResponseBody public void loadVideoFile(HttpServletResponse response) {
try {
String filePath = "E://video//26.mov";
int fileSize = (int) new File(filePath).length();
response.setContentLength(fileSize);
response.setContentType("video/quicktime");
FileInputStream inputStream = new FileInputStream(filePath);
ServletOutputStream outputStream = response.getOutputStream();
int value = IOUtils.copy(inputStream, outputStream);
System.out.println("File Size :: "+fileSize);
System.out.println("Copied Bytes :: "+value);
IOUtils.closeQuietly(inputStream);
IOUtils.closeQuietly(outputStream);
response.setStatus(HttpServletResponse.SC_OK);
} catch (java.io.FileNotFoundException e) {
response.setStatus(HttpStatus.NOT_FOUND.value());
} catch (Exception e) {
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
}
}
JW Player如何出现: