我尝试从 Spring Restful Web 服务中读取视频。 我的网络服务是用 SpringBoot (tomcat) 启动的,我的 html 是在 apache http 服务器上加载的。
我可以观看或下载视频,但我无法在视频中自定义时间跳转。 当可以从网络服务(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>
你知道这个麻烦吗?
最佳答案
我找到了这个类的解决方案:MultpartFileSender -> https://gist.github.com/davinkevin/b97e39d7ce89198774b4
关于java - 如何使用 Spring RESTful Web 服务观看视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38693796/