You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Media.java 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.vaadin.tests.components.media;
  2. import com.vaadin.server.ExternalResource;
  3. import com.vaadin.shared.ui.PreloadMode;
  4. import com.vaadin.tests.components.TestBase;
  5. import com.vaadin.ui.Audio;
  6. import com.vaadin.ui.Button;
  7. import com.vaadin.ui.CheckBox;
  8. import com.vaadin.ui.Video;
  9. public class Media extends TestBase {
  10. @Override
  11. protected void setup() {
  12. final Video v = new Video("video");
  13. v.setSources(new ExternalResource(
  14. "http://techslides.com/demos/sample-videos/small.ogv"));
  15. v.setWidth("560px");
  16. v.setHeight("320px");
  17. addComponent(v);
  18. addComponent(new Button("Play video", event -> v.play()));
  19. addComponent(new Button("Pause video", event -> v.pause()));
  20. final CheckBox loop = new CheckBox("Loop");
  21. loop.addValueChangeListener(event -> v.setLoop(event.getValue()));
  22. addComponent(loop);
  23. v.setPreload(PreloadMode.METADATA);
  24. final Audio a = new Audio("audio");
  25. a.setSources(new ExternalResource(
  26. "http://www.sample-videos.com/audio/mp3/crowd-cheering.mp3"));
  27. addComponent(a);
  28. addComponent(new Button("Play audio", event -> a.play()));
  29. addComponent(new Button("Pause audio", event -> a.pause()));
  30. }
  31. @Override
  32. protected String getDescription() {
  33. return "Video and audio files should play using the HTML5 elements. "
  34. + "(Movie is from http://techslides.com/sample-webm-ogg-and-mp4-video-files-for-html5)";
  35. }
  36. @Override
  37. protected Integer getTicketNumber() {
  38. return 6909;
  39. }
  40. }