Thursday, September 10, 2015

How to run Video file in GWT project


Use following belwo given code to execute file bbb_trailer_360p.webm of type webm to run on the screen using GWT application.

Video videoPlayer = Video.createIfSupported();
if (videoPlayer == null) {
RootPanel.get().add(new Label("Your browser doesn't support HTML5 Video"));
return;
}
//Video videoPlayer = new Video("siddhugwtvideoexample/videos/bbb_trailer_3601p.webm");

videoPlayer.addSource("siddhugwtvideoexample/videos/bbb_trailer_360p.webm", VideoElement.TYPE_WEBM);
videoPlayer.setControls(true);
videoPlayer.setPoster("siddhugwtvideoexample/videos/bbb480.jpg");
videoPlayer.setPixelSize(960, 640);
RootPanel.get().add(videoPlayer);



There is also another method which gives you addition control to run the file on the screen for that we need follwing jar files

https://code.google.com/p/gwt-html5-video/downloads/list

VideoWidget videoPlayer = new VideoWidget(true, false, null);

List sources = new ArrayList();
sources.add(new VideoSource("siddhugwtvideoexample/videos/bbb_trailer_3601p.webm", VideoType.WEBM));

videoPlayer.setSources(sources);
videoPlayer.setControls(true);
videoPlayer.setAutoPlay(false);
videoPlayer.setPoster("siddhugwtvideoexample/videos/bbb480.jpg");
videoPlayer.setPixelSize(960, 640);
RootPanel.get().add(videoPlayer);








No comments: