use of org.mycore.media.video.MCRMediaSourceProvider in project mycore by MyCoRe-Org.
the class MCRXMLFunctions method getSources.
public static NodeList getSources(String derivateId, String path, String userAgent) throws IOException, ParserConfigurationException, URISyntaxException {
MCRMediaSourceProvider provider = new MCRMediaSourceProvider(derivateId, path, Optional.ofNullable(userAgent), () -> EMPTY_ARRAY);
List<MCRMediaSource> sources = provider.getSources();
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
return new NodeList() {
@Override
public Node item(int index) {
Element source = document.createElement("source");
source.setAttribute("src", sources.get(index).getUri());
source.setAttribute("type", sources.get(index).getType().getMimeType());
return source;
}
@Override
public int getLength() {
return sources.size();
}
};
}
use of org.mycore.media.video.MCRMediaSourceProvider in project mycore by MyCoRe-Org.
the class MCRJWPlayerResource method getSources.
@GET
@Path("{derivateId}/{path: .+}/sources.json")
@Produces({ "application/javascript" })
public String getSources(@PathParam("derivateId") String derivateId, @PathParam("path") String path) throws URISyntaxException, IOException {
MCRObjectID derivate = MCRJerseyUtil.getID(derivateId);
MCRJerseyUtil.checkDerivateReadPermission(derivate);
try {
MCRMediaSourceProvider formatter = new MCRMediaSourceProvider(derivateId, path, Optional.ofNullable(request.getHeader("User-Agent")), () -> Arrays.stream(Optional.ofNullable(request.getQueryString()).orElse("").split("&")).filter(p -> !p.startsWith("callback=")).toArray(String[]::new));
return toJson(formatter.getSources());
} catch (NoSuchFileException e) {
LogManager.getLogger().warn("Could not find video file.", e);
throw new WebApplicationException(Status.NOT_FOUND);
}
}
Aggregations