use of org.corpus_tools.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 = Helper.getCorpusPath(input.getDocument().getGraph(), input.getDocument());
String binaryServletPath = "";
String mimeType = null;
String corpusName = corpusPath.get(corpusPath.size() - 1);
CorporaApi api = new CorporaApi(Helper.getClient(input.getUI()));
try {
List<String> files = api.listFiles(corpusName, Joiner.on('/').join(Lists.reverse(corpusPath)));
for (String f : files) {
String guessedMimeType = tika.detect(f);
if (guessedMimeType != null && guessedMimeType.startsWith("audio/")) {
binaryServletPath = input.getContextPath() + "/Binary?" + "file=" + urlParamEscape.escape(f) + "&toplevelCorpusName=" + urlParamEscape.escape(corpusName);
mimeType = guessedMimeType;
}
}
} catch (ApiException e) {
ExceptionDialog.show(e, UI.getCurrent());
}
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;
}
use of org.corpus_tools.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 = Helper.getCorpusPath(input.getDocument().getGraph(), input.getDocument());
String binaryServletPath = "";
String mimeType = null;
String corpusName = corpusPath.get(corpusPath.size() - 1);
CorporaApi api = new CorporaApi(Helper.getClient(input.getUI()));
try {
List<String> files = api.listFiles(corpusName, Joiner.on('/').join(Lists.reverse(corpusPath)));
for (String f : files) {
String guessedMimeType = tika.detect(f);
if (guessedMimeType != null && guessedMimeType.startsWith("video/")) {
binaryServletPath = input.getContextPath() + "/Binary?" + "file=" + urlParamEscape.escape(f) + "&toplevelCorpusName=" + urlParamEscape.escape(corpusName);
mimeType = guessedMimeType;
}
}
} catch (ApiException e) {
ExceptionDialog.show(e, UI.getCurrent());
}
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 org.corpus_tools.annis.gui.components.medialement.MediaElementPlayer in project ANNIS by korpling.
the class AnnisUITest method tokenSearchDialog.
@Test
void tokenSearchDialog() throws Exception {
executeTokenSearch("dialog.demo", 102, 1);
// Test that there is a grid visualizer
SingleResultPanel resultPanel = _find(SingleResultPanel.class).get(0);
GridComponent gridVis = _get(resultPanel, GridComponent.class, spec -> spec.withPredicate(g -> !(g instanceof KWICComponent)));
AnnotationGrid annoGrid = _get(gridVis, AnnotationGrid.class);
ArrayList<Row> tokens = annoGrid.getRowsByAnnotation().get("default_ns::norm0");
assertEquals(1, tokens.size());
assertEquals(Arrays.asList("äh", "fang", "einfach", "mal", "an"), tokens.get(0).getEvents().stream().map(GridEvent::getValue).collect(Collectors.toList()));
// Open the video visualizer and check that media component is loaded
Button btOpenVisualizer = _get(resultPanel, Button.class, spec -> spec.withCaption("video"));
_click(btOpenVisualizer);
awaitCondition(120, () -> !_find(resultPanel, MediaElementPlayer.class).isEmpty());
MediaElementPlayer player = _get(resultPanel, MediaElementPlayer.class, spec -> spec.withCount(1));
assertEquals("video/webm", player.getState().getMimeType());
assertEquals("/Binary?file=dialog.demo%2Fdialog.demo%2Fdialog.demo.webm&toplevelCorpusName=dialog.demo", player.getState().getResourceURL());
// Close the visualizer again
_click(btOpenVisualizer);
awaitCondition(120, () -> _find(resultPanel, MediaElementPlayer.class).isEmpty());
}
Aggregations