问题描述:
video之前加载短一点的视频链接没有问题 , 但是如果现在加载大文件视频的话就会非常慢 , 现在我们可以分段请求视频内容
后台代码如下:
@RequestMapping(value = "/videoPlayer", method = RequestMethod.GET)
public void player2(HttpServletRequest request, HttpServletResponse response) {
String path = request.getServletContext().getRealPath("/static/my/video/interview.mp4");
BufferedInputStream bis = null;
try {
File file = new File(path);
if (file.exists()) {
long p = 0L;
long toLength = 0L;
long contentLength = 0L;
int rangeSwitch = 0;
long fileLength;
String rangBytes = "";
fileLength = file.length();
// get file content
InputStream ins = new FileInputStream(file);
bis = new BufferedInputStream(ins);
// tell the client to allow acce