I would like to embed a Youtube video in a Vaadin 8 app. The only plugin I found is MediaElementsJSPlayer which does not support version 8. Is there any way to accomplish this?
Asked
Active
Viewed 387 times
2 Answers
2
Have you tried Emdedded
or Video
classes to display video? Both of those should work.
For the Embedded
there is an example here: Vaadin framework play Video
And for Video
here at official sampler : Video
Also other StackOverflow questions on the same topic:

anasmi
- 2,562
- 1
- 13
- 25
1
You can use a Label
with the ContendMode
set to ContentMode.HTML
to display pretty much every HTML content.
Example:
@Override
protected void init(VaadinRequest vaadinRequest) {
final VerticalLayout layout = new VerticalLayout();
Label video = new Label();
video.setValue("<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/dQw4w9WgXcQ\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>"); // Replace this with your actual html
video.setContentMode(ContentMode.HTML);
layout.addComponents(video);
setContent(layout);
}
You can get the html to embed your video by clicking share and select embed.

Julius Hörger
- 383
- 3
- 11
-
If you want to embed video using `iframe`. then a better way to go is to use `BrowserFrame ` as descrebed here [Embedded Resources](https://vaadin.com/docs/v8/framework/components/components-embedded.html). There is no need to use label instead – anasmi Apr 29 '19 at 08:27