Class HTMLMediaElement

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.htmlunit.corejs.javascript.ConstProperties, org.htmlunit.corejs.javascript.debug.DebuggableObject, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.SymbolScriptable
    Direct Known Subclasses:
    HTMLAudioElement, HTMLVideoElement

    public class HTMLMediaElement
    extends HTMLElement
    The JavaScript object HTMLMediaElement.
    See Also:
    Serialized Form
    • Field Detail

      • HAVE_NOTHING

        public static final int HAVE_NOTHING
        No information is available about the media resource.
        See Also:
        Constant Field Values
      • HAVE_METADATA

        public static final int HAVE_METADATA
        Enough of the media resource has been retrieved that the metadata attributes are initialized. Seeking will no longer raise an exception.
        See Also:
        Constant Field Values
      • HAVE_CURRENT_DATA

        public static final int HAVE_CURRENT_DATA
        Data is available for the current playback position, but not enough to actually play more than one frame.
        See Also:
        Constant Field Values
      • HAVE_FUTURE_DATA

        public static final int HAVE_FUTURE_DATA
        Data for the current playback position as well as for at least a little bit of time into the future is available (in other words, at least two frames of video, for example).
        See Also:
        Constant Field Values
      • HAVE_ENOUGH_DATA

        public static final int HAVE_ENOUGH_DATA
        Enough data is available—and the download rate is high enough—that the media can be played through to the end without interruption.
        See Also:
        Constant Field Values
      • NETWORK_EMPTY

        public static final int NETWORK_EMPTY
        There is no data yet.
        See Also:
        Constant Field Values
      • NETWORK_LOADING

        public static final int NETWORK_LOADING
        The media is loading.
        See Also:
        Constant Field Values
      • NETWORK_NO_SOURCE

        public static final int NETWORK_NO_SOURCE
        There is no source.
        See Also:
        Constant Field Values
    • Constructor Detail

      • HTMLMediaElement

        public HTMLMediaElement()
        Creates an instance.
    • Method Detail

      • canPlayType

        public java.lang.String canPlayType​(java.lang.String type)
        Determines whether the specified media type can be played back.
        Parameters:
        type - the type
        Returns:
        "probably", "maybe", or ""
      • play

        public java.lang.Object play()
        Begins playback of the media.
        Returns:
        a Promise which is fulfilled when playback has been started, or is rejected if for any reason playback cannot be started
      • pause

        public void pause()
        Pauses playback of the media.
      • load

        public void load()
        Resets the media element to its initial state and begins the process of selecting a media source and loading the media in preparation for playback to begin at the beginning.
      • getNodeType

        public int getNodeType()
        Gets the JavaScript property nodeType for the current node.
        Overrides:
        getNodeType in class Node
        Returns:
        the node type
      • getNodeName

        public java.lang.String getNodeName()
        Gets the JavaScript property nodeName for the current node.
        Overrides:
        getNodeName in class HTMLElement
        Returns:
        the node name
      • getNodeNameCustomize

        protected java.lang.String getNodeNameCustomize()
      • getSrc

        public java.lang.String getSrc()
        Returns the URL of the audio to embed.
        Returns:
        the value of the src attribute
      • setSrc

        public void setSrc​(java.lang.String src)
        Sets the value of the src attribute.
        Parameters:
        src - the value of the src attribute
      • getCurrentSrc

        public java.lang.String getCurrentSrc()
        Returns the absolute URL of the chosen media resource. This could happen, for example, if the web server selects a media file based on the resolution of the user's display. The value is an empty string if the networkState property is EMPTY.
        Returns:
        the absolute URL of the chosen media resource