处理视频第一次加载慢的问题

This commit is contained in:
wenc000 2020-06-27 18:41:47 +08:00
parent 2c6f7e25b1
commit ab042b367d

View File

@ -251,6 +251,8 @@ public class FileServiceImpl extends AbstractService implements IFileService {
* @param contentLength
*/
private void setRangeHeader(long startRange, long endRange, HttpServletResponse response, String fileId, long contentLength) {
// 这里不设置会出现第一次加载很慢的情况
response.setHeader("Content-Length", String.valueOf(contentLength - startRange));
response.setHeader("Content-Range", String.format("bytes %d-%d/%d", startRange, endRange, contentLength));
response.setHeader("Accept-Ranges", "bytes");
response.setHeader("Etag", fileId);