Package com.google.gwt.dom.client
Class MediaElement
- java.lang.Object
-
- com.google.gwt.core.client.JavaScriptObject
-
- com.google.gwt.dom.client.Node
-
- com.google.gwt.dom.client.Element
-
- com.google.gwt.dom.client.MediaElement
-
- Direct Known Subclasses:
AudioElement,VideoElement
public class MediaElement extends Element
Common superclass for Audio and Video elements. See {@link W3C HTML5 Video and Audio}
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCAN_PLAY_MAYBEConstant returned fromcanPlayType(String).static java.lang.StringCAN_PLAY_PROBABLYConstant returned fromcanPlayType(String).static java.lang.StringCANNOT_PLAYConstant returned fromcanPlayType(String).static intHAVE_CURRENT_DATAConstant returned fromgetReadyState().static intHAVE_ENOUGH_DATAConstant returned fromgetReadyState().static intHAVE_FUTURE_DATAConstant returned fromgetReadyState().static intHAVE_METADATAConstant returned fromgetReadyState().static intHAVE_NOTHINGConstant returned fromgetReadyState().static intNETWORK_EMPTYConstant returned fromgetNetworkState().static intNETWORK_IDLEConstant returned fromgetNetworkState().static intNETWORK_LOADINGConstant returned fromgetNetworkState().static intNETWORK_NO_SOURCEConstant returned fromgetNetworkState().static java.lang.StringPRELOAD_AUTOConstant used bygetPreload()andsetPreload(String).static java.lang.StringPRELOAD_METADATAConstant used bygetPreload()andsetPreload(String).static java.lang.StringPRELOAD_NONEConstant used bygetPreload()andsetPreload(String).-
Fields inherited from class com.google.gwt.dom.client.Element
DRAGGABLE_AUTO, DRAGGABLE_FALSE, DRAGGABLE_TRUE
-
Fields inherited from class com.google.gwt.dom.client.Node
DOCUMENT_NODE, ELEMENT_NODE, TEXT_NODE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMediaElement()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringcanPlayType(java.lang.String type)Returnstrueif the native player is capable of playing content of the given MIME type.TimeRangesgetBuffered()Returns aTimeRangesobject indicating which portions of the source have been buffered locally.java.lang.StringgetCurrentSrc()Returns the URL of the current media source, or the empty String if no source is set.doublegetCurrentTime()Returns the current time within the source media stream.doublegetDefaultPlaybackRate()Returns the default playback rate, where 1.0 corresponds to normal playback.doublegetDuration()Returns the duration of the source media stream, in seconds.MediaErrorgetError()Returns the type of error that has occurred while attempting to load and play the media.doublegetInitialTime()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.intgetNetworkState()Returns the network state, one ofNETWORK_EMPTY,NETWORK_IDLE,NETWORK_LOADING, orNETWORK_NO_SOURCE.doublegetPlaybackRate()Returns the playback rate, where 1.0 corresponds to normal playback.TimeRangesgetPlayed()Returns aTimeRangesobject indicating which portions of the source have been played.java.lang.StringgetPreload()intgetReadyState()Returns the current state of the media with respect to rendering the current playback position, as one of the constantsHAVE_CURRENT_DATA,HAVE_ENOUGH_DATA,HAVE_FUTURE_DATA,HAVE_METADATA, orHAVE_NOTHING.TimeRangesgetSeekable()Returns aTimeRangesobject indicating which portions of the source are seekable.java.lang.StringgetSrc()Returns the source URL for the media, ornullif none is set.doublegetStartOffsetTime()Returns the time corresponding to the zero time in the media timeline, measured in seconds since midnight, January 1 1970 UTC, orDouble.NaNif none is specified.doublegetVolume()Returns the current audio volume setting for the media, as a number between 0.0 and 1.0.booleanhasControls()Returnstrueif the media player should display interactive controls (for example, to control play/pause, seek position, and volume),falseotherwise.booleanhasEnded()Returnstrueif playback has reached the end of the media,falseotherwise.booleanisAutoplay()Returnstrueif autoplay is enabled,falseotherwise.booleanisLoop()Returnstrueif the user agent is to seek back to the start of the media once playing has ended,falseotherwise.booleanisMuted()Returnstrueif the volume is to be muted (overriding the normal volume setting),falseotherwise.booleanisPaused()Returnstrueif playback is paused,falseotherwise.booleanisSeeking()Returnstrueif the playback position is in the process of changing discontinuously, e.g., by use of the interactive controls,falseotherwise.voidload()Causes the resource to be loaded.voidpause()Causes playback of the resource to be paused.voidplay()Causes playback of the resource to be started or resumed.voidsetAutoplay(boolean autoplay)Enables or disables autoplay of the resource.voidsetControls(boolean controls)Enables or disables interactive controls.voidsetCurrentTime(double time)Sets the current playback time within the media stream, in seconds.voidsetDefaultPlaybackRate(double rate)Sets the default playback rate.voidsetLoop(boolean loop)Enables or disables looping.voidsetMuted(boolean muted)Enables or disables muting.voidsetPlaybackRate(double rate)Sets the playback rate.voidsetPreload(java.lang.String preload)voidsetSrc(java.lang.String url)Sets the source URL for the media.voidsetVolume(double volume)Sets the playback volume.-
Methods inherited from class com.google.gwt.dom.client.Element
addClassName, as, as, blur, dispatchEvent, focus, getAbsoluteBottom, getAbsoluteLeft, getAbsoluteRight, getAbsoluteTop, getAttribute, getClassName, getClientHeight, getClientWidth, getDir, getDraggable, getElementsByTagName, getFirstChildElement, getId, getInnerHTML, getInnerText, getLang, getNextSiblingElement, getOffsetHeight, getOffsetLeft, getOffsetParent, getOffsetTop, getOffsetWidth, getPreviousSiblingElement, getPropertyBoolean, getPropertyDouble, getPropertyInt, getPropertyJSO, getPropertyObject, getPropertyString, getScrollHeight, getScrollLeft, getScrollTop, getScrollWidth, getString, getStyle, getTabIndex, getTagName, getTitle, hasAttribute, hasClassName, hasTagName, indexOfName, is, is, removeAttribute, removeClassName, replaceClassName, scrollIntoView, setAttribute, setClassName, setDir, setDraggable, setId, setInnerHTML, setInnerSafeHtml, setInnerText, setLang, setPropertyBoolean, setPropertyDouble, setPropertyInt, setPropertyJSO, setPropertyObject, setPropertyString, setScrollLeft, setScrollTop, setTabIndex, setTitle, toggleClassName
-
Methods inherited from class com.google.gwt.dom.client.Node
appendChild, cloneNode, getChild, getChildCount, getChildNodes, getFirstChild, getLastChild, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentElement, getParentNode, getPreviousSibling, hasChildNodes, hasParentElement, insertAfter, insertBefore, insertFirst, isOrHasChild, removeAllChildren, removeChild, removeFromParent, replaceChild, setNodeValue
-
Methods inherited from class com.google.gwt.core.client.JavaScriptObject
cast, createArray, createArray, createFunction, createObject, equals, hashCode, toSource, toString
-
-
-
-
Field Detail
-
CAN_PLAY_PROBABLY
public static final java.lang.String CAN_PLAY_PROBABLY
Constant returned fromcanPlayType(String).- See Also:
- Constant Field Values
-
CAN_PLAY_MAYBE
public static final java.lang.String CAN_PLAY_MAYBE
Constant returned fromcanPlayType(String).- See Also:
- Constant Field Values
-
CANNOT_PLAY
public static final java.lang.String CANNOT_PLAY
Constant returned fromcanPlayType(String).- See Also:
- Constant Field Values
-
HAVE_NOTHING
public static final int HAVE_NOTHING
Constant returned fromgetReadyState().- See Also:
- Constant Field Values
-
HAVE_METADATA
public static final int HAVE_METADATA
Constant returned fromgetReadyState().- See Also:
- Constant Field Values
-
HAVE_CURRENT_DATA
public static final int HAVE_CURRENT_DATA
Constant returned fromgetReadyState().- See Also:
- Constant Field Values
-
HAVE_FUTURE_DATA
public static final int HAVE_FUTURE_DATA
Constant returned fromgetReadyState().- See Also:
- Constant Field Values
-
HAVE_ENOUGH_DATA
public static final int HAVE_ENOUGH_DATA
Constant returned fromgetReadyState().- See Also:
- Constant Field Values
-
NETWORK_EMPTY
public static final int NETWORK_EMPTY
Constant returned fromgetNetworkState().- See Also:
- Constant Field Values
-
NETWORK_IDLE
public static final int NETWORK_IDLE
Constant returned fromgetNetworkState().- See Also:
- Constant Field Values
-
NETWORK_LOADING
public static final int NETWORK_LOADING
Constant returned fromgetNetworkState().- See Also:
- Constant Field Values
-
NETWORK_NO_SOURCE
public static final int NETWORK_NO_SOURCE
Constant returned fromgetNetworkState().- See Also:
- Constant Field Values
-
PRELOAD_AUTO
public static final java.lang.String PRELOAD_AUTO
Constant used bygetPreload()andsetPreload(String).- See Also:
- Constant Field Values
-
PRELOAD_METADATA
public static final java.lang.String PRELOAD_METADATA
Constant used bygetPreload()andsetPreload(String).- See Also:
- Constant Field Values
-
PRELOAD_NONE
public static final java.lang.String PRELOAD_NONE
Constant used bygetPreload()andsetPreload(String).- See Also:
- Constant Field Values
-
-
Method Detail
-
canPlayType
public final java.lang.String canPlayType(java.lang.String type)
Returnstrueif the native player is capable of playing content of the given MIME type.- Parameters:
type- a String representing a MIME type- Returns:
- one of
CAN_PLAY_PROBABLY,CAN_PLAY_MAYBE, orCANNOT_PLAY
-
getBuffered
public final TimeRanges getBuffered()
Returns aTimeRangesobject indicating which portions of the source have been buffered locally.- Returns:
- a
TimeRangesinstance, ornull.
-
getCurrentSrc
public final java.lang.String getCurrentSrc()
Returns the URL of the current media source, or the empty String if no source is set.- Returns:
- a String URL
-
getCurrentTime
public final double getCurrentTime()
Returns the current time within the source media stream.- Returns:
- the time, in seconds, as a double
- See Also:
setCurrentTime(double)
-
getDefaultPlaybackRate
public final double getDefaultPlaybackRate()
Returns the default playback rate, where 1.0 corresponds to normal playback. If no rate has been set, 1.0 is returned.- Returns:
- the current default playback rate, or 1.0 if it has not been set
- See Also:
setDefaultPlaybackRate(double)
-
getDuration
public final double getDuration()
Returns the duration of the source media stream, in seconds. If the duration is unknown,Double.NaNis returned. For unbounded media streams,Double.POSITIVE_INFINITYis returned.- Returns:
- a positive duration in seconds, NaN, or Infinity
-
getError
public final MediaError getError()
Returns the type of error that has occurred while attempting to load and play the media. If no error has occurred,nullis returned.- Returns:
- a
MediaErrorinstance, ornull
-
getInitialTime
public final 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.- Returns:
- the initial time, or 0.0 if unknown
-
getNetworkState
public final int getNetworkState()
Returns the network state, one ofNETWORK_EMPTY,NETWORK_IDLE,NETWORK_LOADING, orNETWORK_NO_SOURCE.- Returns:
- an integer constant indicating the network state
- See Also:
NETWORK_EMPTY,NETWORK_IDLE,NETWORK_LOADING,NETWORK_NO_SOURCE
-
getPlaybackRate
public final double getPlaybackRate()
Returns the playback rate, where 1.0 corresponds to normal playback. If the rate has not been set, 1.0 is returned.- Returns:
- the playback rate, if known, otherwise 1.0
- See Also:
setPlaybackRate(double)
-
getPlayed
public final TimeRanges getPlayed()
Returns aTimeRangesobject indicating which portions of the source have been played.- Returns:
- a
TimeRangesinstance, ornull.
-
getPreload
public final java.lang.String getPreload()
- Returns:
- the preload setting
- See Also:
setPreload(String),PRELOAD_AUTO,PRELOAD_METADATA,PRELOAD_NONE
-
getReadyState
public final int getReadyState()
Returns the current state of the media with respect to rendering the current playback position, as one of the constantsHAVE_CURRENT_DATA,HAVE_ENOUGH_DATA,HAVE_FUTURE_DATA,HAVE_METADATA, orHAVE_NOTHING.- Returns:
- an integer constant indicating the ready state
- See Also:
HAVE_CURRENT_DATA,HAVE_ENOUGH_DATA,HAVE_FUTURE_DATA,HAVE_METADATA,HAVE_NOTHING
-
getSeekable
public final TimeRanges getSeekable()
Returns aTimeRangesobject indicating which portions of the source are seekable.- Returns:
- a
TimeRangesinstance, ornull.
-
getSrc
public final java.lang.String getSrc()
Returns the source URL for the media, ornullif none is set.- Returns:
- a String URL or
null - See Also:
setSrc(String)
-
getStartOffsetTime
public final double getStartOffsetTime()
Returns the time corresponding to the zero time in the media timeline, measured in seconds since midnight, January 1 1970 UTC, orDouble.NaNif none is specified.- Returns:
- the start time
-
getVolume
public final double getVolume()
Returns the current audio volume setting for the media, as a number between 0.0 and 1.0.- Returns:
- a number between 0.0 (silent) and 1.0 (loudest)
- See Also:
setVolume(double)
-
hasControls
public final boolean hasControls()
Returnstrueif the media player should display interactive controls (for example, to control play/pause, seek position, and volume),falseotherwise.- Returns:
- whether controls should be displayed
- See Also:
setControls(boolean)
-
hasEnded
public final boolean hasEnded()
Returnstrueif playback has reached the end of the media,falseotherwise.- Returns:
- whether playback has ended
-
isAutoplay
public final boolean isAutoplay()
Returnstrueif autoplay is enabled,falseotherwise. When autoplay is enabled, the user agent will begin playback automatically as soon as it can do so without stopping.- Returns:
- the autoplay setting
- See Also:
setAutoplay(boolean)
-
isLoop
public final boolean isLoop()
Returnstrueif the user agent is to seek back to the start of the media once playing has ended,falseotherwise.- Returns:
- the loop setting
- See Also:
setLoop(boolean)
-
isMuted
public final boolean isMuted()
Returnstrueif the volume is to be muted (overriding the normal volume setting),falseotherwise.- Returns:
- the muting setting
- See Also:
setMuted(boolean),getVolume(),setVolume(double)
-
isPaused
public final boolean isPaused()
Returnstrueif playback is paused,falseotherwise.
-
isSeeking
public final boolean isSeeking()
Returnstrueif the playback position is in the process of changing discontinuously, e.g., by use of the interactive controls,falseotherwise.- Returns:
- the seeking status
- See Also:
setControls(boolean),hasControls()
-
load
public final void load()
Causes the resource to be loaded.
-
pause
public final void pause()
Causes playback of the resource to be paused.
-
play
public final void play()
Causes playback of the resource to be started or resumed.
-
setAutoplay
public final void setAutoplay(boolean autoplay)
Enables or disables autoplay of the resource.- Parameters:
autoplay- iftrue, enable autoplay- See Also:
isAutoplay()
-
setControls
public final void setControls(boolean controls)
Enables or disables interactive controls.- Parameters:
controls- iftrue, enable controls- See Also:
hasControls()
-
setCurrentTime
public final void setCurrentTime(double time)
Sets the current playback time within the media stream, in seconds.- Parameters:
time- a number within the ranges given bygetSeekable()- See Also:
getCurrentTime()
-
setDefaultPlaybackRate
public final void setDefaultPlaybackRate(double rate)
Sets the default playback rate.- Parameters:
rate- a double value- See Also:
getDefaultPlaybackRate()
-
setLoop
public final void setLoop(boolean loop)
Enables or disables looping.- Parameters:
loop- iftrue, enable looping- See Also:
isLoop()
-
setMuted
public final void setMuted(boolean muted)
Enables or disables muting.- Parameters:
muted- iftrue, enable muting- See Also:
isMuted()
-
setPlaybackRate
public final void setPlaybackRate(double rate)
Sets the playback rate.- Parameters:
rate- a double value- See Also:
getPlaybackRate()
-
setPreload
public final void setPreload(java.lang.String preload)
- Parameters:
preload- a String constants- See Also:
getPreload(),setPreload(String),PRELOAD_AUTO,PRELOAD_METADATA,PRELOAD_NONE
-
setSrc
public final void setSrc(java.lang.String url)
Sets the source URL for the media.- Parameters:
url- a String URL- See Also:
getSrc()
-
setVolume
public final void setVolume(double volume)
Sets the playback volume.- Parameters:
volume- a value between 0.0 (silent) and 1.0 (loudest)- See Also:
getVolume()
-
-