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.

Video.java 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright 2011 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.server.ResourceReference;
  19. import com.vaadin.shared.ui.video.VideoState;
  20. /**
  21. * The Video component translates into an HTML5 <video> element and as
  22. * such is only supported in browsers that support HTML5 media markup. Browsers
  23. * that do not support HTML5 display the text or HTML set by calling
  24. * {@link #setAltText(String)}.
  25. *
  26. * A flash-player fallback can be implemented by setting HTML content allowed (
  27. * {@link #setHtmlContentAllowed(boolean)} and calling
  28. * {@link #setAltText(String)} with the flash player markup. An example of flash
  29. * fallback can be found at the <a href=
  30. * "https://developer.mozilla.org/En/Using_audio_and_video_in_Firefox#Using_Flash"
  31. * >Mozilla Developer Network</a>.
  32. *
  33. * Multiple sources can be specified. Which of the sources is used is selected
  34. * by the browser depending on which file formats it supports. See <a
  35. * href="http://en.wikipedia.org/wiki/HTML5_video#Table">wikipedia</a> for a
  36. * table of formats supported by different browsers.
  37. *
  38. * @author Vaadin Ltd
  39. * @since 6.7.0
  40. */
  41. public class Video extends AbstractMedia {
  42. @Override
  43. protected VideoState getState() {
  44. return (VideoState) super.getState();
  45. }
  46. public Video() {
  47. this("", null);
  48. }
  49. /**
  50. * @param caption
  51. * The caption for this video.
  52. */
  53. public Video(String caption) {
  54. this(caption, null);
  55. }
  56. /**
  57. * @param caption
  58. * The caption for this video.
  59. * @param source
  60. * The Resource containing the video to play.
  61. */
  62. public Video(String caption, Resource source) {
  63. setCaption(caption);
  64. setSource(source);
  65. setShowControls(true);
  66. }
  67. /**
  68. * Sets the poster image, which is shown in place of the video before the
  69. * user presses play.
  70. *
  71. * @param poster
  72. */
  73. public void setPoster(Resource poster) {
  74. getState().setPoster(ResourceReference.create(poster));
  75. }
  76. /**
  77. * @return The poster image.
  78. */
  79. public Resource getPoster() {
  80. return ResourceReference.getResource(getState().getPoster());
  81. }
  82. }