前台是正常的video标签,
由于要播放多个视频,所以用js控制改变video的src属性.
输出视频流工具类
public static void download(HttpServletResponse response,String path,String name){
try {
OutputStream out = null;//输出响应正文的输出流
InputStream in = null;//读取本地文件的输入流
File file = new File(path);
try {
in = new FileInputStream(file);
response.setContentType("video/mpeg4");
out = response.getOutputStream();
int byteRead = 0;
byte[] buffer = new byte[512];
while((byteRead = in.read(buffer)) != -1) {
out.write(buffer, 0, byteRead);
}
} catch (Exception e) {
e.printStackTrace();
} finally{
in.close();
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
下面是异常的截图:![图片说明](https://img-ask.csdn.net/upload/201612/07/1481091341_513145.png)