2016-08-01 75 views
2

我尝试从Spring Restful Web服务中读取视频。 我的web服务使用SpringBoot(tomcat)启动,我的html被加载到apache http服务器上。如何使用Spring RESTful Web服务观看视频

我可以观看或下载视频,但我无法在视频中自定义时间跳转。 当从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> 

你知道这个麻烦吗?

回答