Play video in Vaadin

2019-06-08 15:15发布

问题:

I'm a beginner with Vaadin, and I have a problem when play video. The video always plays with file size of video although I set fixed dimensions. Anyone can help me? Thanks so much!

My code :

public class VideoPreview extends CssLayout{

    Video video;

    public VideoPreview(String uri) {
        video = new Video(null, new ExternalResource(uri, "video/mp4"));
        video.setAltText("Can't play video");
        video.setAutoplay(true);
        video.setWidth("320px");
        video.setHeight("265px");
        addComponent(video);
    }
} 

回答1:

Can you check this code from vaadin sampler :

   Embedded e = new Embedded(null, new ExternalResource(
               "http://www.youtube.com/v/meXvxkn1Y_8&hl=en_US&fs=1&"));
       e.setAlternateText("Vaadin Eclipse Quickstart video");
       e.setMimeType("application/x-shockwave-flash");
       e.setParameter("allowFullScreen", "true");
       e.setWidth("320px");
       e.setHeight("265px");
       addComponent(e);

It works for me both chrome and firefox. I think your firefox addons may cause this problem.



标签: video vaadin