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.

Audio.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright 2000-2018 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.ui;
  17. import com.vaadin.server.Resource;
  18. import com.vaadin.shared.ui.audio.AudioState;
  19. /**
  20. * The Audio component translates into an HTML5 <audio> element and as
  21. * such is only supported in browsers that support HTML5 media markup. Browsers
  22. * that do not support HTML5 display the text or HTML set by calling
  23. * {@link #setAltText(String)}.
  24. *
  25. * A flash-player fallback can be implemented by setting HTML content allowed (
  26. * {@link #setHtmlContentAllowed(boolean)} and calling
  27. * {@link #setAltText(String)} with the flash player markup. An example of flash
  28. * fallback can be found at the <a href=
  29. * "https://developer.mozilla.org/En/Using_audio_and_video_in_Firefox#Using_Flash"
  30. * >Mozilla Developer Network</a>.
  31. *
  32. * Multiple sources can be specified. Which of the sources is used is selected
  33. * by the browser depending on which file formats it supports. See
  34. * <a href="http://en.wikipedia.org/wiki/HTML5_video#Table">wikipedia</a> for a
  35. * table of formats supported by different browsers.
  36. *
  37. * @author Vaadin Ltd
  38. * @since 6.7.0
  39. */
  40. public class Audio extends AbstractMedia {
  41. public Audio() {
  42. this("", null);
  43. }
  44. /**
  45. * @param caption
  46. * The caption of the audio component.
  47. */
  48. public Audio(String caption) {
  49. this(caption, null);
  50. }
  51. /**
  52. * @param caption
  53. * The caption of the audio component
  54. * @param source
  55. * The audio file to play.
  56. */
  57. public Audio(String caption, Resource source) {
  58. setCaption(caption);
  59. setSource(source);
  60. setShowControls(true);
  61. }
  62. @Override
  63. protected AudioState getState() {
  64. return (AudioState) super.getState();
  65. }
  66. @Override
  67. protected AudioState getState(boolean markAsDirty) {
  68. return (AudioState) super.getState(markAsDirty);
  69. }
  70. }