Can I play video using Vaadin framewotk ? The main idea is loading video files from local drive in flv or avi formats and play it in web using vaadin framework. Thanks.
5 Answers
There is a sample in the Sampler: http://demo.vaadin.com/sampler/#FlashEmbed You can see the source by clicking 'view source', and it will show you something like this:
Embedded e = new Embedded(null, new ExternalResource(
"http://www.youtube.com/v/meXvxkn1Y_8&hl=en_US&fs=1&"));
e.setMimeType("application/x-shockwave-flash");
e.setParameter("allowFullScreen", "true");
e.setWidth("320px");
e.setHeight("265px");
addComponent(e);
Obviously, you'll want to change the ExternalResource to something else (e.g FileResource, ClassResource, StreamResource, ...) in order to play local files.

- 451
- 4
- 4
-
Thanks for answer, I have tried to play external videos like youtube and so on, works good, but I have problem with playing internal .flv files, I've tried File, Stream and other resources , changed Mime Type to video/x-flv but result is negative :(. Could you help me ? – jitm Mar 02 '11 at 11:28
Vaadin version 6.7 brought a new class Video that uses the new HTML5 "video" element to embed video on a page.
My posting on the Vaadin Forum provides the source code for an example app.
The main part of that code, when populating a window or layout:
Video v = new Video( "video" ); // Instantiate video player widget.
// Specify a list of your video in one or more formats.
// Different browsers support various different video formats.
v.setSources(
new ExternalResource( "http://www.example.com/media/example_video.mp4" ),
new ExternalResource( "http://www.example.com/media/example_video.ogv" )
);
v.setWidth( "640px" ); // Set size of the video player's display area on-screen.
v.setHeight( "360px" );
this.addComponent( v ); // Add the component to the window or layout.
Oops, I just re-read you posting -- you want to play local video files. Do you mean local to the user's computer or the Vaadin app server-side computer? Either way, you may be able to manipulate the "ExternalResource" seen above, or another subclass of Vaadin Resource to access a local file.

- 303,325
- 100
- 852
- 1,154
-
I am using this Video class to view video files, but it is giving error "No video with supported format and MIME type found". I have tried with .flv,.mp4,.mpg files, but same result. I am working with Vaadin 6.7.9. – Yogesh Kulkarni Jun 30 '12 at 10:19
NOTE: This is for local files:
FileResource fileResource = new FileResource(new File("/Users/user/Downloads/DBTI_1991_teaser_HD.mp4"));
Video vd = new Video();
vd.setAutoplay(true);
vd.setSource(fileResource);
this.addComponent(vd);

- 11
- 1
Another alternative is the Vaadin add-on "YouTubePlayer" if you want to access a video specifically from YouTube.com.

- 303,325
- 100
- 852
- 1,154