java.lang.Object
org.htmlunit.BrowserVersion.MediaResourceType
- All Implemented Interfaces:
Serializable
- Enclosing class:
- BrowserVersion
Represents a media type that a browser can play, combining a MIME type
with an optional set of codecs.
Instances are immutable.
Instances are used as keys in the two lookup sets held by each
BrowserVersion (maybeMediaResource_ and
probablyMediaResources_) and are queried by
BrowserVersion.canPlayType(String) to determine the value
returned by the HTMLMediaElement.canPlayType() DOM method:
"maybe"— the MIME type alone is in themaybeMediaResource_set (no codec information given)."probably"— the MIME type together with the specific codec list is in theprobablyMediaResources_set.""— neither set contains a matching entry.
Equality and hashing are based on both the MIME type string and the
normalised codec string, so new MediaResourceType("video/mp4", null)
and new MediaResourceType("video/mp4", "avc1.42E01E") are
considered distinct entries.
-
Constructor Summary
ConstructorsConstructorDescriptionMediaResourceType(String mime, String codecs) Creates a newMediaResourceTypewith the given MIME type and optional codec string. -
Method Summary
-
Constructor Details
-
MediaResourceType
Creates a newMediaResourceTypewith the given MIME type and optional codec string.- Parameters:
mime- the MIME type, e.g."audio/ogg"; must not benullcodecs- the normalised codec list, e.g."opus"or"avc1.42E01E,mp4a.40.2", ornullif no codec information is associated with this entry
-
-
Method Details
-
parse
Parses a rawcanPlayType()argument string into aMediaResourceTypesuitable for a set lookup.The parsing rules follow the HTML Living Standard:
- Blank or whitespace-only input returns
null(the caller will map this to""). - If a semicolon (
;) is present, everything before it is treated as the MIME type and the remainder is inspected for acodecsparameter. - When a
codecsparameter is found its value is normalised: surrounding quotes are stripped, individual codec tokens are trimmed and sorted alphabetically, then re-joined with a comma. This ensures that"vp8, vorbis"and"vorbis,vp8"resolve to the same entry. - A
codecskey without a value (e.g."video/mp4; codecs") is treated as if no codec information were present, yielding a codec ofnull. - Input without a semicolon is used verbatim as the MIME type
with a
nullcodec.
- Parameters:
mediaResourceType- the raw string passed toHTMLMediaElement.canPlayType(), e.g."video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\""- Returns:
- the parsed
MediaResourceType, ornullif the input is blank (indicating an immediate""result)
- Blank or whitespace-only input returns
-
hashCode
public int hashCode() -
equals
-