我尝试阅读Spring Restful Web Services中的视频。 我的Web服务是用SpringBoot(tomcat)启动的,我的html是在apache http server上加载的。
我可以观看或下载视频,但我无法在视频中自定义时间跳转。 当从Web服务(src =“http:// localhost:8080 / maVideo”)访问视频时存在此问题,但当从apache服务器访问视频时它不存在(src =“media / maVideo” “)。
这是我的Java代码:
@CrossOrigin
@RequestMapping(value = "/videoSimple/{hash}", method = RequestMethod.GET, headers = "Accept=application/media")
public ResponseEntity<InputStreamResource> videoSimple(final HttpSession session, @PathVariable final String hash) throws IOException {
final String fileName = "/4_videoToto.mp4";
final ClassPathResource classPathResource = new ClassPathResource("medias/" + fileName);
final HttpHeaders headers = createHttpHeaders(fileName, classPathResource);
final ResponseEntity<InputStreamResource> response = new ResponseEntity<>(new InputStreamResource(classPathResource.getInputStream()), headers, HttpStatus.OK);
return response;
}
这是我的HTML代码。
<video id="video_telechargeable" width="360" height="250" controls>
<source src="http://localhost:8080/maVideo" type="video/mp4">
</video>
你知道这个麻烦吗?
答案 0 :(得分:1)
我找到了这个类的解决方案:MultpartFileSender - &gt; https://gist.github.com/davinkevin/b97e39d7ce89198774b4