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;
}
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;
}
Aggregations