public abstract class MediaBase extends FocusWidget implements HasAllMediaHandlers
A widget representing a media element.
Experimental API: This API is still under development and is subject to change.
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabledDEBUG_ID_PREFIX| Modifier | Constructor and Description | 
|---|---|
| protected  | MediaBase(MediaElement element)Protected constructor. | 
| Modifier and Type | Method and Description | 
|---|---|
| HandlerRegistration | addCanPlayThroughHandler(CanPlayThroughHandler handler)Adds a  CanPlayThroughEventhandler. | 
| HandlerRegistration | addEndedHandler(EndedHandler handler)Adds a  EndedEventhandler. | 
| HandlerRegistration | addLoadedMetadataHandler(LoadedMetadataHandler handler)Adds a  LoadedMetadataEventhandler. | 
| HandlerRegistration | addProgressHandler(ProgressHandler handler)Adds a  ProgressEventhandler. | 
| SourceElement | addSource(java.lang.String url)Add a source element to this media. | 
| SourceElement | addSource(java.lang.String url,
         java.lang.String type)Add a source element to this media, specifying the type (format) of the
 media. | 
| java.lang.String | canPlayType(java.lang.String type)Returns  trueif the native player is capable of playing content of
 the given MIME type. | 
| TimeRanges | getBuffered()Returns a  TimeRangesobject indicating which portions of the source
 have been buffered locally. | 
| java.lang.String | getCurrentSrc()Returns the URL of the current media source, or the empty String if no
 source is set. | 
| double | getCurrentTime()Returns the current time within the source media stream. | 
| double | getDefaultPlaybackRate()Returns the default playback rate, where 1.0 corresponds to normal
 playback. | 
| double | getDuration()Returns the duration of the source media stream, in seconds. | 
| MediaError | getError()Returns the type of error that has occurred while attempting to load and
 play the media. | 
| double | getInitialTime()Returns the time to which the media stream was seeked at the time it was
 loaded, in seconds, or 0.0 if the position is unknown. | 
| MediaElement | getMediaElement()Returns the attached Media Element. | 
| int | getNetworkState()Returns the network state, one of  MediaElement.NETWORK_EMPTY,MediaElement.NETWORK_IDLE,MediaElement.NETWORK_LOADING, orMediaElement.NETWORK_NO_SOURCE. | 
| double | getPlaybackRate()Returns the playback rate, where 1.0 corresponds to normal playback. | 
| TimeRanges | getPlayed()Returns a  TimeRangesobject indicating which portions of the source
 have been played. | 
| java.lang.String | getPreload()Returns the preload setting, one of  MediaElement.PRELOAD_AUTO,MediaElement.PRELOAD_METADATA, orMediaElement.PRELOAD_NONE. | 
| int | getReadyState()Returns the current state of the media with respect to rendering the
 current playback position, as one of the constants
  MediaElement.HAVE_CURRENT_DATA,MediaElement.HAVE_ENOUGH_DATA,MediaElement.HAVE_FUTURE_DATA,MediaElement.HAVE_METADATA,
 orMediaElement.HAVE_NOTHING. | 
| TimeRanges | getSeekable()Returns a  TimeRangesobject indicating which portions of the source
 are seekable. | 
| java.lang.String | getSrc()Returns the source URL for the media, or  nullif none is set. | 
| double | getStartOffsetTime()Returns the time corresponding to the zero time in the media timeline,
 measured in seconds since midnight, January 1 1970 UTC, or
  Double.NaNif none is specified. | 
| double | getVolume()Returns the current audio volume setting for the media, as a number between
 0.0 and 1.0. | 
| boolean | hasControls()Returns  trueif the media player should display interactive
 controls (for example, to control play/pause, seek position, and volume),falseotherwise. | 
| boolean | hasEnded()Returns  trueif playback has reached the end of the media,falseotherwise. | 
| boolean | isAutoplay()Returns  trueif autoplay is enabled,falseotherwise. | 
| boolean | isLoop()Returns  trueif the user agent is to seek back to the start of the
 media once playing has ended,falseotherwise. | 
| boolean | isMuted()Returns  trueif the volume is to be muted (overriding the normal
 volume setting),falseotherwise. | 
| boolean | isPaused()Returns  trueif playback is paused,falseotherwise. | 
| boolean | isSeeking()Returns  trueif the playback position is in the process of changing
 discontinuously, e.g., by use of the interactive controls,falseotherwise. | 
| void | load()Causes the resource to be loaded. | 
| void | pause()Causes playback of the resource to be paused. | 
| void | play()Causes playback of the resource to be started or resumed. | 
| void | removeSource(SourceElement source)Remove the specified  SourceElementfrom this media. | 
| void | setAutoplay(boolean autoplay)Enables or disables autoplay of the resource. | 
| void | setControls(boolean controls)Enables or disables interactive controls. | 
| void | setCurrentTime(double time)Sets the current playback time within the media stream, in seconds. | 
| void | setDefaultPlaybackRate(double rate)Sets the default playback rate. | 
| void | setLoop(boolean loop)Enables or disables looping. | 
| void | setMuted(boolean muted)Enables or disables muting. | 
| void | setPlaybackRate(double rate)Sets the playback rate. | 
| void | setPreload(java.lang.String preload)Changes the preload setting to one of  MediaElement.PRELOAD_AUTO,MediaElement.PRELOAD_METADATA, orMediaElement.PRELOAD_NONE. | 
| void | setSrc(java.lang.String url)Sets the source URL for the media. | 
| void | setVolume(double volume)Sets the playback volume. | 
addBlurHandler, addClickHandler, addClickListener, addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addFocusHandler, addFocusListener, addGestureChangeHandler, addGestureEndHandler, addGestureStartHandler, addKeyboardListener, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler, getFocusImpl, getTabIndex, isEnabled, onAttach, removeClickListener, removeFocusListener, removeKeyboardListener, removeMouseListener, removeMouseWheelListener, setAccessKey, setEnabled, setFocus, setTabIndexaddAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEventsaddStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitfireEventprotected MediaBase(MediaElement element)
public HandlerRegistration addCanPlayThroughHandler(CanPlayThroughHandler handler)
HasCanPlayThroughHandlersCanPlayThroughEvent handler.addCanPlayThroughHandler in interface HasCanPlayThroughHandlershandler - the media CanPlayThrough handlerHandlerRegistration used to remove this handlerpublic HandlerRegistration addEndedHandler(EndedHandler handler)
HasEndedHandlersEndedEvent handler.addEndedHandler in interface HasEndedHandlershandler - the media ended handlerHandlerRegistration used to remove this handlerpublic HandlerRegistration addProgressHandler(ProgressHandler handler)
HasProgressHandlersProgressEvent handler.addProgressHandler in interface HasProgressHandlershandler - the media progress handlerHandlerRegistration used to remove this handlerpublic HandlerRegistration addLoadedMetadataHandler(LoadedMetadataHandler handler)
HasLoadedMetadataHandlersLoadedMetadataEvent handler.addLoadedMetadataHandler in interface HasLoadedMetadataHandlershandler - the media loadedmetadata handlerHandlerRegistration used to remove this handlerpublic SourceElement addSource(java.lang.String url)
 Only use this method if you do not know the type of the source file, as the
 browser cannot determine the format from the filename and must download
 each source until a compatible one is found. Instead, you should specify
 the type for the media using addSource(String, String) so the
 browser can choose a source file without downloading the file.
 
url - a String URLaddSource(String, String)public SourceElement addSource(java.lang.String url, java.lang.String type)
 The type is the format or encoding of the media represented by the source
 element. For example, the type of an
 AudioElement could be one of
 "audio/ogg",
 AudioElement.TYPE_MP3, or
 AudioElement.TYPE_WAV.
 
 You can also add the codec information to the type, giving the browser even
 more information about whether or not it can play the file (Example: "
 audio/ogg; codec=vorbis");
 
url - a String URLtype - the type (format) of the mediagetSrc()public java.lang.String canPlayType(java.lang.String type)
true if the native player is capable of playing content of
 the given MIME type.type - a String representing a MIME typeMediaElement.CAN_PLAY_PROBABLY,
         MediaElement.CAN_PLAY_MAYBE, or
         MediaElement.CANNOT_PLAYpublic TimeRanges getBuffered()
TimeRanges object indicating which portions of the source
 have been buffered locally.TimeRanges instance, or null.public java.lang.String getCurrentSrc()
public double getCurrentTime()
setCurrentTime(double)public double getDefaultPlaybackRate()
setDefaultPlaybackRate(double)public double getDuration()
Double.NaN is returned. For unbounded media
 streams, Double.POSITIVE_INFINITY is returned.public MediaError getError()
null is returned.MediaError instance, or nullpublic double getInitialTime()
public MediaElement getMediaElement()
public int getNetworkState()
MediaElement.NETWORK_EMPTY,
 MediaElement.NETWORK_IDLE, MediaElement.NETWORK_LOADING, or
 MediaElement.NETWORK_NO_SOURCE.MediaElement.NETWORK_EMPTY, 
MediaElement.NETWORK_IDLE, 
MediaElement.NETWORK_LOADING, 
MediaElement.NETWORK_NO_SOURCEpublic double getPlaybackRate()
setPlaybackRate(double)public TimeRanges getPlayed()
TimeRanges object indicating which portions of the source
 have been played.TimeRanges instance, or null.public java.lang.String getPreload()
MediaElement.PRELOAD_AUTO,
 MediaElement.PRELOAD_METADATA, or
 MediaElement.PRELOAD_NONE.setPreload(String), 
MediaElement.PRELOAD_AUTO, 
MediaElement.PRELOAD_METADATA, 
MediaElement.PRELOAD_NONEpublic int getReadyState()
MediaElement.HAVE_CURRENT_DATA,
 MediaElement.HAVE_ENOUGH_DATA,
 MediaElement.HAVE_FUTURE_DATA, MediaElement.HAVE_METADATA,
 or MediaElement.HAVE_NOTHING .MediaElement.HAVE_CURRENT_DATA, 
MediaElement.HAVE_ENOUGH_DATA, 
MediaElement.HAVE_FUTURE_DATA, 
MediaElement.HAVE_METADATA, 
MediaElement.HAVE_NOTHINGpublic TimeRanges getSeekable()
TimeRanges object indicating which portions of the source
 are seekable.TimeRanges instance, or null.public java.lang.String getSrc()
null if none is set.nullsetSrc(String)public double getStartOffsetTime()
Double.NaN if none is specified.public double getVolume()
setVolume(double)public boolean hasControls()
true if the media player should display interactive
 controls (for example, to control play/pause, seek position, and volume),
 false otherwise.setControls(boolean)public boolean hasEnded()
true if playback has reached the end of the media, false otherwise.public boolean isAutoplay()
true if autoplay is enabled, false otherwise. When
 autoplay is enabled, the user agent will begin playback automatically as
 soon as it can do so without stopping.setAutoplay(boolean)public boolean isLoop()
true if the user agent is to seek back to the start of the
 media once playing has ended, false otherwise.setLoop(boolean)public boolean isMuted()
true if the volume is to be muted (overriding the normal
 volume setting), false otherwise.setMuted(boolean), 
getVolume(), 
setVolume(double)public boolean isPaused()
true if playback is paused, false otherwise.public boolean isSeeking()
true if the playback position is in the process of changing
 discontinuously, e.g., by use of the interactive controls, false
 otherwise.setControls(boolean), 
hasControls()public void load()
public void pause()
public void play()
public void removeSource(SourceElement source)
SourceElement from this media. If the source
 element is not a child of this widget, it will not be removed.source - the source element to removeaddSource(String, String)public void setAutoplay(boolean autoplay)
autoplay - if true, enable autoplayisAutoplay()public void setControls(boolean controls)
controls - if true, enable controlshasControls()public void setCurrentTime(double time)
time - a number within the ranges given by getSeekable()getCurrentTime()public void setDefaultPlaybackRate(double rate)
rate - a double valuegetDefaultPlaybackRate()public final void setLoop(boolean loop)
loop - if true, enable loopingisLoop()public void setMuted(boolean muted)
muted - if true, enable mutingisMuted()public void setPlaybackRate(double rate)
rate - a double valuegetPlaybackRate()public void setPreload(java.lang.String preload)
MediaElement.PRELOAD_AUTO,
 MediaElement.PRELOAD_METADATA, or
 MediaElement.PRELOAD_NONE.preload - a String constantsgetPreload(), 
setPreload(String), 
MediaElement.PRELOAD_AUTO, 
MediaElement.PRELOAD_METADATA, 
MediaElement.PRELOAD_NONEpublic void setSrc(java.lang.String url)
 Support for different media types varies between browsers. Instead of using
 this method, you should encode your media in multiple formats and add all
 of them using addSource(String, String) so the browser can choose
 a source that it supports.
 
url - a String URLgetSrc(), 
addSource(String, String)public void setVolume(double volume)
volume - a value between 0.0 (silent) and 1.0 (loudest)getVolume()