Search in sources :

Example 1 with MediaElementPlayer

use of annis.gui.components.medialement.MediaElementPlayer in project ANNIS by korpling.

the class VideoVisualizer method createComponent.

@Override
public MediaElementPlayer createComponent(VisualizerInput input, VisualizationToggle visToggle) {
    List<String> corpusPath = CommonHelper.getCorpusPath(input.getDocument().getGraph(), input.getDocument());
    String binaryServletPath = "";
    String corpusName = corpusPath.get(corpusPath.size() - 1);
    String documentName = corpusPath.get(0);
    corpusName = urlPathEscape.escape(corpusName);
    documentName = urlPathEscape.escape(documentName);
    WebResource resMeta = Helper.getAnnisWebResource().path("meta/binary").path(corpusName).path(documentName);
    List<AnnisBinaryMetaData> meta = resMeta.get(new GenericType<List<AnnisBinaryMetaData>>() {
    });
    // if there is no document at all don't fail
    String mimeType = meta.size() > 0 ? null : "video/webm";
    for (AnnisBinaryMetaData m : meta) {
        if (m.getMimeType().startsWith("video/")) {
            mimeType = m.getMimeType();
            break;
        }
    }
    Validate.notNull(mimeType, "There must be at least one binary file for the document with a video mime type");
    String mimeTypeEncoded = mimeType;
    mimeTypeEncoded = urlParamEscape.escape(mimeType);
    binaryServletPath = input.getContextPath() + "/Binary?" + "documentName=" + documentName + "&toplevelCorpusName=" + corpusName + "&mime=" + mimeTypeEncoded;
    MediaElementPlayer player = new MediaElementPlayer(MediaElement.video, binaryServletPath, mimeType);
    if (VaadinSession.getCurrent().getAttribute(MediaController.class) != null) {
        VaadinSession.getCurrent().getAttribute(MediaController.class).addMediaPlayer(player, input.getId(), visToggle);
    }
    return player;
}
Also used : MediaController(annis.libgui.media.MediaController) MediaElementPlayer(annis.gui.components.medialement.MediaElementPlayer) WebResource(com.sun.jersey.api.client.WebResource) AnnisBinaryMetaData(annis.service.objects.AnnisBinaryMetaData) List(java.util.List)

Example 2 with MediaElementPlayer

use of annis.gui.components.medialement.MediaElementPlayer in project ANNIS by korpling.

the class AudioVisualizer method createComponent.

@Override
public MediaElementPlayer createComponent(VisualizerInput input, VisualizationToggle visToggle) {
    List<String> corpusPath = CommonHelper.getCorpusPath(input.getDocument().getGraph(), input.getDocument());
    String binaryServletPath = "";
    String corpusName = corpusPath.get(corpusPath.size() - 1);
    String documentName = corpusPath.get(0);
    corpusName = urlPathEscape.escape(corpusName);
    documentName = urlPathEscape.escape(documentName);
    WebResource resMeta = Helper.getAnnisWebResource().path("meta/binary").path(corpusName).path(documentName);
    List<AnnisBinaryMetaData> meta = resMeta.get(new GenericType<List<AnnisBinaryMetaData>>() {
    });
    // if there is no document at all don't fail
    String mimeType = meta.size() > 0 ? null : "audio/ogg";
    for (AnnisBinaryMetaData m : meta) {
        if (m.getMimeType().startsWith("audio/")) {
            mimeType = m.getMimeType();
            break;
        }
    }
    Validate.notNull(mimeType, "There must be at least one binary file for the document with a audio mime type");
    String mimeTypeEncoded = mimeType;
    mimeTypeEncoded = urlParamEscape.escape(mimeType);
    binaryServletPath = input.getContextPath() + "/Binary?" + "documentName=" + documentName + "&toplevelCorpusName=" + corpusName + "&mime=" + mimeTypeEncoded;
    MediaElementPlayer player = new MediaElementPlayer(MediaElement.audio, binaryServletPath, mimeType);
    if (VaadinSession.getCurrent().getAttribute(MediaController.class) != null) {
        VaadinSession.getCurrent().getAttribute(MediaController.class).addMediaPlayer(player, input.getId(), visToggle);
    }
    return player;
}
Also used : MediaController(annis.libgui.media.MediaController) MediaElementPlayer(annis.gui.components.medialement.MediaElementPlayer) WebResource(com.sun.jersey.api.client.WebResource) AnnisBinaryMetaData(annis.service.objects.AnnisBinaryMetaData) List(java.util.List)

Aggregations

MediaElementPlayer (annis.gui.components.medialement.MediaElementPlayer)2 MediaController (annis.libgui.media.MediaController)2 AnnisBinaryMetaData (annis.service.objects.AnnisBinaryMetaData)2 WebResource (com.sun.jersey.api.client.WebResource)2 List (java.util.List)2