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.

AudioTest.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package com.vaadin.tests.components.media;
  2. import com.vaadin.server.ClassResource;
  3. import com.vaadin.server.Resource;
  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. public class AudioTest extends TestBase {
  9. @Override
  10. protected void setup() {
  11. // Public domain sounds from pdsounds.org 27.2.2013
  12. final Resource[] s1 = { new ClassResource(getClass(), "bip.mp3"),
  13. new ClassResource(getClass(), "bip.ogg") };
  14. final Resource[] s2 = {
  15. new ClassResource(getClass(), "toyphone_dialling.mp3"),
  16. new ClassResource(getClass(), "toyphone_dialling.ogg") };
  17. final Audio audio = new Audio();
  18. audio.setSources(s1);
  19. audio.setShowControls(true);
  20. audio.setHtmlContentAllowed(true);
  21. audio.setAltText("Can't <b>play</b> media");
  22. audio.setAutoplay(true);
  23. addComponent(audio);
  24. CheckBox checkBox = new CheckBox("Show controls");
  25. checkBox.setValue(audio.isShowControls());
  26. checkBox.addValueChangeListener(
  27. event -> audio.setShowControls(event.getValue()));
  28. addComponent(checkBox);
  29. checkBox = new CheckBox("HtmlContentAllowed");
  30. checkBox.setValue(audio.isHtmlContentAllowed());
  31. checkBox.addValueChangeListener(
  32. event -> audio.setHtmlContentAllowed(event.getValue()));
  33. addComponent(checkBox);
  34. checkBox = new CheckBox("muted");
  35. checkBox.setValue(audio.isMuted());
  36. checkBox.addValueChangeListener(
  37. event -> audio.setMuted(event.getValue()));
  38. addComponent(checkBox);
  39. checkBox = new CheckBox("autoplay");
  40. checkBox.setValue(audio.isAutoplay());
  41. checkBox.addValueChangeListener(
  42. event -> audio.setAutoplay(event.getValue()));
  43. addComponent(checkBox);
  44. Button b = new Button("Change", event -> audio.setSources(s2));
  45. addComponent(b);
  46. getLayout().setHeight("400px");
  47. getLayout().setExpandRatio(b, 1.0f);
  48. }
  49. @Override
  50. protected String getDescription() {
  51. return "Should autoplay, manipulating checkboxes should do appropriate thing, button changes file.";
  52. }
  53. @Override
  54. protected Integer getTicketNumber() {
  55. return 11160;
  56. }
  57. }