Module org.htmlunit

Class HtmlMedia

All Implemented Interfaces:
Serializable, Cloneable, Element, Node
Direct Known Subclasses:
HtmlAudio, HtmlVideo

public abstract class HtmlMedia extends HtmlElement
HTML Media element, e.g. HtmlAudio or HtmlVideo.
Author:
Ahmed Ashour, Frank Danek, Ronald Brill
See Also:
  • Method Details

    • onAddedToPage

      protected void onAddedToPage()
      Lifecycle method invoked whenever a node is added to a page. Intended to be overridden by nodes which need to perform custom logic when they are added to a page. This method is recursive, so if you override it, please be sure to call super.onAddedToPage(). Hides the nonce attribute if required by the Content-Security-Policy. Checks the url against the Content-Security-Policy (media-src); the source and track children are checked after they are added.
      Overrides:
      onAddedToPage in class DomElement
    • onAllChildrenAddedToPage

      public void onAllChildrenAddedToPage(boolean postponed)
      Lifecycle method invoked after a node and all its children have been added to a page, during parsing of the HTML. Intended to be overridden by nodes which need to perform custom logic after they and all their child nodes have been processed by the HTML parser. This method is not recursive, and the default implementation is empty, so there is no need to call super.onAllChildrenAddedToPage() if you implement this method.
      Overrides:
      onAllChildrenAddedToPage in class DomNode
      Parameters:
      postponed - whether to use PostponedAction or no
    • setAttributeNS

      protected void setAttributeNS(String namespaceURI, String qualifiedName, String value, boolean notifyAttributeChangeListeners, boolean notifyMutationObservers)
      Sets the value of the attribute specified by namespace and qualified name. Checks the new src url against the Content-Security-Policy (media-src); like the browsers, also if the element is not attached to the page.
      Overrides:
      setAttributeNS in class HtmlElement
      Parameters:
      namespaceURI - the URI that identifies an XML namespace
      qualifiedName - the qualified name (prefix:local) of the attribute
      value - the value of the attribute
      notifyAttributeChangeListeners - to notify the associated HtmlAttributeChangeListeners
      notifyMutationObservers - to notify MutationObservers or not
    • getSrcAttribute

      public final String getSrcAttribute()
      Returns the value of the attribute src. Refer to the HTML 4.01 documentation for details on the use of this attribute.
      Returns:
      the value of the attribute src or an empty string if that attribute isn't defined
    • getSrc

      public String getSrc()
      Returns the fully qualified source URL.
      Returns:
      the fully qualified value of the src attribute
    • setSrc

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

      public 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