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.

VAudio.java 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal.gwt.client.ui;
  5. import com.google.gwt.dom.client.AudioElement;
  6. import com.google.gwt.dom.client.Document;
  7. import com.google.gwt.dom.client.Style;
  8. import com.google.gwt.dom.client.Style.Unit;
  9. import com.google.gwt.user.client.ui.Widget;
  10. import com.vaadin.terminal.gwt.client.ApplicationConnection;
  11. import com.vaadin.terminal.gwt.client.BrowserInfo;
  12. import com.vaadin.terminal.gwt.client.UIDL;
  13. public class VAudio extends VMediaBase {
  14. private static String CLASSNAME = "v-audio";
  15. private AudioElement audio;
  16. public VAudio() {
  17. audio = Document.get().createAudioElement();
  18. setMediaElement(audio);
  19. setStyleName(CLASSNAME);
  20. }
  21. @Override
  22. public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
  23. if (client.updateComponent(this, uidl, true)) {
  24. return;
  25. }
  26. super.updateFromUIDL(uidl, client);
  27. Style style = audio.getStyle();
  28. // Make sure that the controls are not clipped if visible.
  29. if (shouldShowControls(uidl)
  30. && (style.getHeight() == null || "".equals(style.getHeight()))) {
  31. if (BrowserInfo.get().isChrome()) {
  32. style.setHeight(32, Unit.PX);
  33. } else {
  34. style.setHeight(25, Unit.PX);
  35. }
  36. }
  37. }
  38. @Override
  39. protected String getDefaultAltHtml() {
  40. return "Your browser does not support the <code>audio</code> element.";
  41. }
  42. public Widget getWidgetForPaintable() {
  43. return this;
  44. }
  45. }