Search in sources :

Example 1 with MCRMediaSource

use of org.mycore.media.video.MCRMediaSource 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();
        }
    };
}
Also used : MCRMediaSource(org.mycore.media.video.MCRMediaSource) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) MCRMediaSourceProvider(org.mycore.media.video.MCRMediaSourceProvider) Document(org.w3c.dom.Document)

Aggregations

MCRMediaSource (org.mycore.media.video.MCRMediaSource)1 MCRMediaSourceProvider (org.mycore.media.video.MCRMediaSourceProvider)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1 NodeList (org.w3c.dom.NodeList)1