I'm using Spring WebFlux. Here is My Service :
@Service
public class VideoStreamimpl implements IVideoStream {
private static final String FORMAT="classpath:videos/%s.mp4";
@Autowired
private ResourceLoader resourceLoader;
@Override
public Mono<Resource> getVideo(String title){
return Mono.fromSupplier(
()->resourceLoader.getResource(
String.format(FORMAT,title)
)
);
}
}
here's my controller :
@RestController
public class VideoStreamController {
@Autowired
private IVideoStream iVideoStreamimpl;
@GetMapping(value = "videos/{title}" , produces = "video/mp4")
public Mono<Resource> ShowSingleVide(@PathVariable String title , @RequestHeader("Range") String Range){
System.out.println("Range in Bytes() : "+Range);
return iVideoStreamimpl.getVideo(title);
}
}
I found that, the vert x
is better than Spring WebFlux
so I want to use Vert.X
in my project .
How to use Vert.x
in spring to get Video Stream?