Hello,
I download a video from google cloud and convert to inputStream, ( InputStreamResource videoDownloaded = new InputStreamResource(inputStream) ),
I want to put this video into this componet com.vaadin.ui.Video video = new put com.vaadin.ui.Video() after ai want to put Into an HtmlBoxLayout html. How can I do this?
Hi,
If you have a file downloaded, then you can use com.vaadin.server.FileResource
to pass it to a Video player, for instance
Video video = new Video();
Resource resource = new FileResource(...);
video.setSource(resource);
To put video player into HtmlLayout
, you can write the following:
<layout>
<htmlBox>
<templateContents>
<![CDATA[
<div location="videoBox"/>
]]>
</templateContents>
<vbox id="videoBox" width="600px" height="300px"/>
</htmlBox>
</layout>
public class Screen extends AbstractWindow {
@Inject
private VBoxLayout videoBox;
@Override
public void init(Map<String, Object> params) {
Video video = new Video();
Resource resource = new FileResource(...);
video.setSource(resource);
video.setSizeFull();
videoBox.unwrap(Layout.class).addComponent(video);
}
}
Regards,
Gleb
Tnks, this help me.
More one thing :
I’m trying to create in java this components , how i put this part :
<templateContents>
<![CDATA[
<div location="videoBox"/>
]]>
</templateContents>
This way :
Resource source = new FileResource(file);
Video video = new Video();
video.setSource(source);
video.setWidth("100%");
video.setHeight("50%");
VBoxLayout videoBox = componentsFactory.createComponent(VBoxLayout.class);
videoBox.setId("videoBox");
videoBox.setWidth("100%");
videoBox.setHeight("50%");
videoBox.unwrap(com.vaadin.ui.Layout.class).addComponent(video);
HtmlBoxLayout html = componentsFactory.createComponent(HtmlBoxLayout.class);
html.setTemplateName("templateContents");
html.setWidth("100%");
html.setHeight("50%");
html.add(videoBox);
thumbnailsBox.removeAll();
thumbnailsBox.add(html);
You’re able to set the templateContents
attribute by invoking the HtmlLayout.setTemplateContents
method.
Tnks, for help-me.
Att, Luiz Figueiredo