Package com.vaadin.flow.component.html
Class Video
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.HtmlComponent
com.vaadin.flow.component.html.Media
com.vaadin.flow.component.html.Video
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasAriaLabel,com.vaadin.flow.component.HasComponents,com.vaadin.flow.component.HasComponentsOfType<com.vaadin.flow.component.Component>,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,Serializable
Component representing a
<video> element — the browser's
built-in video player.
List the recording in as many formats as you want to support, one
Source each, and the browser plays the first one it can decode:
Video video = new Video();
video.addSource("/intro.webm", "video/webm");
video.addSource("/intro.mp4", "video/mp4");
video.setControlsVisible(true);
video.setPoster("/intro-poster.jpg");
The element has no controls of its own until
Media.setControlsVisible(boolean) is called, so a player that the visitor
is meant to start needs that call. Give the player a size through
HasSize.setWidth(String) and HasSize.setHeight(String); without one, the
page reflows once the video dimensions are known, unless a
poster fixes the size earlier.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.html.Media
Media.Preload -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable StringGets the URL of the poster image.voidsetPoster(com.vaadin.flow.server.streams.DownloadHandler downloadHandler) Sets the poster image to the one that the givenDownloadHandlercallback serves.voidSets the URL of the image to show while the video is downloading, and before it is played for the first time.Methods inherited from class com.vaadin.flow.component.html.Media
addSource, addSource, getPreload, getSources, isAutoplay, isControlsVisible, isLoop, isMuted, setAutoplay, setControlsVisible, setLoop, setMuted, setPreloadMethods inherited from class com.vaadin.flow.component.HtmlComponent
getTitle, setTitleMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, getUIOrThrow, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttachedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasAriaLabel
getAriaLabel, getAriaLabelledBy, setAriaLabel, setAriaLabelledBy, setAriaLabelledByMethods inherited from interface com.vaadin.flow.component.HasComponents
addMethods inherited from interface com.vaadin.flow.component.HasComponentsOfType
add, add, addComponentAsFirst, addComponentAtIndex, bindChildren, getChildren, getComponentAt, getComponentCount, indexOf, remove, remove, removeAll, replaceMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
Video
public Video()Creates a video player without any source. -
Video
Creates a video player that plays the first of the given sources the browser can decode.- Parameters:
sources- the same recording in one or more file formats
-
-
Method Details
-
setPoster
Sets the URL of the image to show while the video is downloading, and before it is played for the first time. Without a poster, the browser shows the first frame of the video, which means it has to download part of the file before there is anything to look at.- Parameters:
poster- the URL of the poster image, ornullto remove the poster
-
setPoster
public void setPoster(com.vaadin.flow.server.streams.DownloadHandler downloadHandler) Sets the poster image to the one that the givenDownloadHandlercallback serves. This is the version to use for an image the application produces itself, rather than one that is served from a URL of its own.Sets the
Content-Dispositionheader toinlinefor pre-defined download handlers, created by factory methods inDownloadHandler, as well as for otherAbstractDownloadHandlerimplementations.The handler is wrapped with
DownloadHandler.allowDisabled()so that the poster is still served when the video, or one of its ancestors, is disabled. The browser fetches it as part of rendering rather than as a user action, so blocking the request on the disabled state would leave the player blank.- Parameters:
downloadHandler- the download handler that serves the poster image, notnull- See Also:
-
getPoster
Gets the URL of the poster image.- Returns:
- the URL of the poster image, or
nullif none has been set - See Also:
-