Permalink
Browse files

[gw] (2) Make <source type> optional. Move canPlayType from navigator…

… to HTMLMediaElement. Make it return a string instead of an integer. Fix up the candidate URL list generation. Make loadstart/play event sequencing deterministic.

git-svn-id: http://svn.whatwg.org/webapps@2404 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information...
1 parent 9bd1a7d commit 911d5fa96b1022be55f0125b1539b8023012d0fa @Hixie Hixie committed Nov 15, 2008
Showing with 233 additions and 128 deletions.
  1. +123 −73 index
  2. +110 −55 source
View
196 index
@@ -17,7 +17,7 @@
<div class=head>
<p><a class=logo href=http://www.whatwg.org/ rel=home><img alt=WHATWG src=/images/logo></a></p>
<h1>HTML 5</h1>
- <h2 class="no-num no-toc" id=draft-recommendation-&mdash;-date:-01-jan-1901>Draft Recommendation &mdash; 14 November 2008</h2>
+ <h2 class="no-num no-toc" id=draft-recommendation-&mdash;-date:-01-jan-1901>Draft Recommendation &mdash; 15 November 2008</h2>
<p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
<p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
<dl><dt>Multiple-page version:</dt>
@@ -437,18 +437,19 @@
<ol>
<li><a href=#error-codes><span class=secno>4.8.10.1 </span>Error codes</a></li>
<li><a href=#location-of-the-media-resource><span class=secno>4.8.10.2 </span>Location of the media resource</a></li>
- <li><a href=#network-states><span class=secno>4.8.10.3 </span>Network states</a></li>
- <li><a href=#loading-the-media-resource><span class=secno>4.8.10.4 </span>Loading the media resource</a></li>
- <li><a href=#offsets-into-the-media-resource><span class=secno>4.8.10.5 </span>Offsets into the media resource</a></li>
- <li><a href=#the-ready-states><span class=secno>4.8.10.6 </span>The ready states</a></li>
- <li><a href=#cue-ranges><span class=secno>4.8.10.7 </span>Cue ranges</a></li>
- <li><a href=#playing-the-media-resource><span class=secno>4.8.10.8 </span>Playing the media resource</a></li>
- <li><a href=#seeking><span class=secno>4.8.10.9 </span>Seeking</a></li>
- <li><a href=#user-interface><span class=secno>4.8.10.10 </span>User interface</a></li>
- <li><a href=#time-ranges><span class=secno>4.8.10.11 </span>Time ranges</a></li>
- <li><a href=#byte-ranges><span class=secno>4.8.10.12 </span>Byte ranges</a></li>
- <li><a href=#mediaevents><span class=secno>4.8.10.13 </span>Event summary</a></li>
- <li><a href=#security-and-privacy-considerations><span class=secno>4.8.10.14 </span>Security and privacy considerations</a></ol></li>
+ <li><a href=#media-types><span class=secno>4.8.10.3 </span>Media types</a></li>
+ <li><a href=#network-states><span class=secno>4.8.10.4 </span>Network states</a></li>
+ <li><a href=#loading-the-media-resource><span class=secno>4.8.10.5 </span>Loading the media resource</a></li>
+ <li><a href=#offsets-into-the-media-resource><span class=secno>4.8.10.6 </span>Offsets into the media resource</a></li>
+ <li><a href=#the-ready-states><span class=secno>4.8.10.7 </span>The ready states</a></li>
+ <li><a href=#cue-ranges><span class=secno>4.8.10.8 </span>Cue ranges</a></li>
+ <li><a href=#playing-the-media-resource><span class=secno>4.8.10.9 </span>Playing the media resource</a></li>
+ <li><a href=#seeking><span class=secno>4.8.10.10 </span>Seeking</a></li>
+ <li><a href=#user-interface><span class=secno>4.8.10.11 </span>User interface</a></li>
+ <li><a href=#time-ranges><span class=secno>4.8.10.12 </span>Time ranges</a></li>
+ <li><a href=#byte-ranges><span class=secno>4.8.10.13 </span>Byte ranges</a></li>
+ <li><a href=#mediaevents><span class=secno>4.8.10.14 </span>Event summary</a></li>
+ <li><a href=#security-and-privacy-considerations><span class=secno>4.8.10.15 </span>Security and privacy considerations</a></ol></li>
<li><a href=#the-canvas-element><span class=secno>4.8.11 </span>The <code>canvas</code> element</a>
<ol>
<li><a href=#the-2d-context><span class=secno>4.8.11.1 </span>The 2D context</a>
@@ -657,8 +658,7 @@
<li><a href=#custom-handlers><span class=secno>5.6.2 </span>Custom protocol and content handlers</a>
<ol>
<li><a href=#security-and-privacy><span class=secno>5.6.2.1 </span>Security and privacy</a></li>
- <li><a href=#sample-handler-impl><span class=secno>5.6.2.2 </span>Sample user interface</a></ol></li>
- <li><a href=#client-abilities><span class=secno>5.6.3 </span>Client abilities</a></ol></li>
+ <li><a href=#sample-handler-impl><span class=secno>5.6.2.2 </span>Sample user interface</a></ol></ol></li>
<li><a href=#offline><span class=secno>5.7 </span>Offline Web applications</a>
<ol>
<li><a href=#introduction-0><span class=secno>5.7.1 </span>Introduction</a></li>
@@ -16698,10 +16698,10 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
<p>The <dfn id=attr-source-type title=attr-source-type><code>type</code></dfn>
attribute gives the type of the <a href=#media-resource>media resource</a>, to help
the user agent determine if it can play this <a href=#media-resource>media
- resource</a> before fetching it. Its value must be a MIME
- type. The <code title="">codecs</code> parameter may be specified
- and might be necessary to specify exactly how the resource is
- encoded. <a href=#refsRFC2046>[RFC2046]</a> <a href=#refsRFC4281>[RFC4281]</a></p>
+ resource</a> before fetching it. If specified, its value must be
+ a MIME type. The <code title="">codecs</code> parameter may be
+ specified and might be necessary to specify exactly how the resource
+ is encoded. <a href=#refsRFC2046>[RFC2046]</a> <a href=#refsRFC4281>[RFC4281]</a></p>
<div class=example>
@@ -16796,11 +16796,6 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
<a href=#media-resource>media resource</a> is useful to the user before fetching
it. Its value must be a valid <a href=#mq>media query</a>. <a href=#refsMQ>[MQ]</a></p>
- <p>Either the <code title=attr-source-type><a href=#attr-source-type>type</a></code> attribute,
- the <code title=attr-source-media><a href=#attr-source-media>media</a></code> attribute or both,
- must be specified, unless this is the last <code><a href=#the-source-element>source</a></code>
- element child of the parent element.</p>
-
<p>The <dfn id=attr-source-pixelratio title=attr-source-pixelratio><code>pixelratio</code></dfn>
attribute allows the author to specify the pixel ratio of anamorphic
<a href=#media-resource title="media resource">media resources</a> that do not
@@ -16861,6 +16856,7 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
readonly attribute <a href=#byteranges>ByteRanges</a> <a href=#dom-media-bufferedbytes title=dom-media-bufferedBytes>bufferedBytes</a>;
readonly attribute unsigned long <a href=#dom-media-totalbytes title=dom-media-totalBytes>totalBytes</a>;
void <a href=#dom-media-load title=dom-media-load>load</a>();
+ DOMString <a href=#dom-navigator-canplaytype title=dom-navigator-canPlayType>canPlayType</a>(in DOMString type);
// ready state
const unsigned short <a href=#dom-media-have_nothing title=dom-media-HAVE_NOTHING>HAVE_NOTHING</a> = 0;
@@ -16949,10 +16945,6 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
task">queued</a> in this section and its subsections is the
<a href=#media-element-event-task-source>media element event task source</a>.</p>
- <p>The <code title=dom-navigator-canPlayType><a href=#dom-navigator-canplaytype>canPlayType()</a></code>
- method can be used to probe the user agent to determine what types
- are supported.</p>
-
<h5 id=error-codes><span class=secno>4.8.10.1 </span>Error codes</h5>
@@ -17086,21 +17078,22 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
<p>If all the following conditions are true:</p>
- <ul><li>The <var title="">candidate</var> element has a <code title=attr-source-src><a href=#attr-source-src>src</a></code> attribute</li>
+ <ul><li>The <var title="">candidate</var> element has a <code title=attr-source-src><a href=#attr-source-src>src</a></code> attribute.</li>
<li><a href=#resolve-a-url title="resolve a url">Resolving</a> the
<a href=#url>URL</a> given by the <var title="">candidate</var>
element's <code title=attr-source-src><a href=#attr-source-src>src</a></code> attribute does
- not fail</li>
+ not fail.</li>
- <li>The <var title="">candidate</var> element has a <code title=attr-source-type><a href=#attr-source-type>type</a></code> attribute and that
- attribute's value, when parsed as a MIME type (including any
- codecs described by the <code title="">codec</code> parameter),
- does not represent a type that the user agent knows it cannot
- render <a href=#refsRFC2046>[RFC2046]</a> <a href=#refsRFC4281>[RFC4281]</a></li>
+ <li>The <var title="">candidate</var> element either has no <code title=attr-source-type><a href=#attr-source-type>type</a></code> attribute, or its <code title=attr-source-type><a href=#attr-source-type>type</a></code> attribute's value, when
+ parsed as a MIME type (including any codecs described by the
+ <code title="">codec</code> parameter), does not represent
+ <a href=#a-type-that-the-user-agent-knows-it-cannot-render>a type that the user agent knows it cannot
+ render</a>.</li>
- <li>The <var title="">candidate</var> element has a <code title=attr-source-media><a href=#attr-source-media>media</a></code> attribute and that
- attribute's value, when processed according to the rules for <a href=#mq>media queries</a>, matches the current environment <a href=#refsMQ>[MQ]</a></li>
+ <li>The <var title="">candidate</var> element either has no <code title=attr-source-media><a href=#attr-source-media>media</a></code> attribute, or its <code title=attr-source-media><a href=#attr-source-media>media</a></code> attribute's value, when
+ processed according to the rules for <a href=#mq>media
+ queries</a>, matches the current environment. <a href=#refsMQ>[MQ]</a></li>
</ul><p>...then append an item to the <var title="">result</var> list
consisting of the <a href=#absolute-url>absolute URL</a> resulting from <a href=#resolve-a-url title="resolve a url">resolving</a> the <a href=#url>URL</a> given
@@ -17120,7 +17113,76 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
<li><p>Return <var title="">result</var>.</li>
- </ol><h5 id=network-states><span class=secno>4.8.10.3 </span>Network states</h5>
+ </ol><h5 id=media-types><span class=secno>4.8.10.3 </span>Media types</h5>
+
+ <p>A <a href=#media-resource>media resource</a> can be described in terms of its
+ <em>type</em>, specifically a MIME type, optionally with a <code title="">codecs</code> parameter. <a href=#refsRFC2046>[RFC2046]</a> <a href=#refsRFC4281>[RFC4281]</a>.</p>
+
+ <p>Types are usually somewhat incomplete descriptions; for example
+ "<code title="">video/mpeg</code>" doesn't say anything except what
+ the container type is, and even a type like "<code title="">video/mp4; codecs="avc1.42E01E,
+ mp4a.40.2"</code>" doesn't include information like the actual
+ bitrate (only the maximum bitrate). Thus, given a type, a user agent
+ can often only know whether it <em>might</em> be able to play
+ media of that type (with varying levels of confidence), or whether
+ it definitely <em>cannot</em> play media of that type.</p>
+
+ <p><dfn id=a-type-that-the-user-agent-knows-it-cannot-render>A type that the user agent knows it cannot render</dfn> is
+ one that describes a resource that the user agent definitely does
+ not support, for example because it doesn't recognise the container
+ type, or it doesn't support the listed codecs.</p>
+
+ <p>The <dfn id=dom-navigator-canplaytype title=dom-navigator-canPlayType><code>canPlayType(<var title="">type</var>)</code></dfn> method must return the string
+ "<code title="">no</code>" if <var title="">type</var> is <a href=#a-type-that-the-user-agent-knows-it-cannot-render>a
+ type that the user agent knows it cannot render</a>; it must
+ return "<code title="">probably</code>" if the user agent is
+ confident that the type represents a <a href=#media-resource>media resource</a>
+ that it can render if used in with this <code><a href=#audio>audio</a></code> or
+ <code><a href=#video>video</a></code> element; and it must return "<code title="">maybe</code>" otherwise. Implementors are encouraged to
+ return "<code title="">maybe</code>" unless the type can be
+ confidently established as being supported or not. Generally, a user
+ agent should never return "<code title="">probably</code>" if the
+ type doesn't have a <code title="">codecs</code> parameter.</p>
+
+ <div class=example>
+
+ <p>This script tests to see if the user agent supports a
+ (fictional) new format to dynamically decide whether to use a
+ <code><a href=#video>video</a></code> element or a plugin:</p>
+
+ <pre>&lt;section id="video"&gt;
+ &lt;p&gt;&lt;a href="playing-cats.nfv"&gt;Download video&lt;/a&gt;&lt;/p&gt;
+&lt;/section&gt;
+&lt;script&gt;
+ var videoSection = document.getElementById('video');
+ var videoElement = document.createElement('video');
+ var support = videoElement.canPlayType('video/x-new-fictional-format;codecs="kittens,bunnies"');
+ if (support != "probably" &amp;&amp; "New Fictional Video Plug-in" in navigator.plugins) {
+ // not confident of browser support
+ // but we have a plugin
+ // so use plugin instead
+ videoElement = document.createElement("embed");
+ } else if (support == "no") {
+ // no support from browser and no plugin
+ // do nothing
+ videoElement = null;
+ }
+ if (videoElement) {
+ while (videoSection.hasChildNodes())
+ videoSection.removeChild(videoSection.firstChild);
+ videoElement.setAttribute("src", "playing-cats.nfv");
+ videoSection.appendChild(videoElement);
+ }
+&lt;/script&gt;</pre>
+
+ </div>
+
+ <p class=note>To express the type of a <a href=#media-resource>media resource</a>
+ to allow the user agent to avoid downloading resources it can't
+ render, authors can use the <code><a href=#the-source-element>source</a></code> element's <code title=attr-source-type><a href=#attr-source-type>type</a></code> attribute.</p>
+
+
+ <h5 id=network-states><span class=secno>4.8.10.4 </span>Network states</h5>
<p>As <a href=#media-element title="media element">media elements</a> interact
with the network, their current network activity is represented by
@@ -17157,7 +17219,7 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
reach the <code title=dom-media-NETWORK_LOADED><a href=#dom-media-network_loaded>NETWORK_LOADED</a></code> state.</p>
- <h5 id=loading-the-media-resource><span class=secno>4.8.10.4 </span>Loading the media resource</h5>
+ <h5 id=loading-the-media-resource><span class=secno>4.8.10.5 </span>Loading the media resource</h5>
<p>All <a href=#media-element title="media element">media elements</a> have a
<dfn id=begun-flag>begun flag</dfn>, which must begin in the false state, and an
@@ -17247,6 +17309,10 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
<li><p>Set the <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> to <code title=dom-media-NETWORK_LOADING><a href=#dom-media-network_loading>NETWORK_LOADING</a></code>.</li>
+ <li><p>Set the <a href=#begun-flag>begun flag</a> to true and <a href=#queue-a-task>queue a
+ task</a> to <a href=#fire-a-progress-event>fire a progress event</a> called <code title=event-loadstart><a href=#event-loadstart>loadstart</a></code> at the <a href=#media-element>media
+ element</a>.</li>
+
<li>
<p>The method must return, but these steps must continue.</p>
@@ -17260,10 +17326,6 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
<!-- SYNCHRONOUS / ASYNCHRONOUS BOUNDARY FOR EVENT DISPATCH -->
- <li><p>Set the <a href=#begun-flag>begun flag</a> to true and <a href=#queue-a-task>queue a
- task</a> to <a href=#fire-a-progress-event>fire a progress event</a> called <code title=event-loadstart><a href=#event-loadstart>loadstart</a></code> at the <a href=#media-element>media
- element</a>.</li>
-
<li>
<p><i>Candidate loop</i>: For each item in <var title="">candidates</var>, if any, and in the same order as they
@@ -17598,7 +17660,7 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
- <h5 id=offsets-into-the-media-resource><span class=secno>4.8.10.5 </span>Offsets into the media resource</h5>
+ <h5 id=offsets-into-the-media-resource><span class=secno>4.8.10.6 </span>Offsets into the media resource</h5>
<p>The <dfn id=dom-media-duration title=dom-media-duration><code>duration</code></dfn>
attribute must return the length of the <a href=#media-resource>media resource</a>,
@@ -17649,7 +17711,7 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
- <h5 id=the-ready-states><span class=secno>4.8.10.6 </span>The ready states</h5>
+ <h5 id=the-ready-states><span class=secno>4.8.10.7 </span>The ready states</h5>
<p><a href=#media-element title="media element">Media elements</a> have a
<i>ready state</i>, which describes to what degree they are ready
@@ -17807,7 +17869,7 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
- <h5 id=cue-ranges><span class=secno>4.8.10.7 </span>Cue ranges</h5>
+ <h5 id=cue-ranges><span class=secno>4.8.10.8 </span>Cue ranges</h5>
<p><a href=#media-element title="media element">Media elements</a> have a set of
<dfn id=cue-range title="cue range">cue ranges</dfn>. Each cue range is made up
@@ -17856,7 +17918,7 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
- <h5 id=playing-the-media-resource><span class=secno>4.8.10.8 </span>Playing the media resource</h5>
+ <h5 id=playing-the-media-resource><span class=secno>4.8.10.9 </span>Playing the media resource</h5>
<p>The <dfn id=dom-media-paused title=dom-media-paused><code>paused</code></dfn>
attribute represents whether the <a href=#media-element>media element</a> is
@@ -18019,7 +18081,7 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
<li><p>If the fourth step above changed the value of <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code>, the user agent must
<a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a>
- called <code title=event-pause><a href=#event-pause>play</a></code> at the
+ called <code title=event-play><a href=#event-play>play</a></code> at the
element.</li>
</ol><hr><p>When the <dfn id=dom-media-pause title=dom-media-pause><code>pause()</code></dfn>
@@ -18163,7 +18225,7 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
- <h5 id=seeking><span class=secno>4.8.10.9 </span>Seeking</h5>
+ <h5 id=seeking><span class=secno>4.8.10.10 </span>Seeking</h5>
<p>The <dfn id=dom-media-seeking title=dom-media-seeking><code>seeking</code></dfn>
attribute must initially have the value false.</p>
@@ -18258,7 +18320,7 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
- <h5 id=user-interface><span class=secno>4.8.10.10 </span>User interface</h5>
+ <h5 id=user-interface><span class=secno>4.8.10.11 </span>User interface</h5>
<p>The <dfn id=attr-media-controls title=attr-media-controls><code>controls</code></dfn>
attribute is a <a href=#boolean-attribute>boolean attribute</a>. If the attribute is
@@ -18327,7 +18389,7 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
- <h5 id=time-ranges><span class=secno>4.8.10.11 </span>Time ranges</h5>
+ <h5 id=time-ranges><span class=secno>4.8.10.12 </span>Time ranges</h5>
<p>Objects implementing the <code><a href=#timeranges>TimeRanges</a></code> interface
represent a list of ranges (periods) of time.</p>
@@ -18374,7 +18436,7 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
- <h5 id=byte-ranges><span class=secno>4.8.10.12 </span>Byte ranges</h5>
+ <h5 id=byte-ranges><span class=secno>4.8.10.13 </span>Byte ranges</h5>
<p>Objects implementing the <code><a href=#byteranges>ByteRanges</a></code> interface
represent a list of ranges of bytes.</p>
@@ -18420,7 +18482,7 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
- <h5 id=mediaevents><span class=secno>4.8.10.13 </span>Event summary</h5>
+ <h5 id=mediaevents><span class=secno>4.8.10.14 </span>Event summary</h5>
<p>The following events fire on <a href=#media-element title="media element">media
elements</a> as part of the processing model described above:</p>
@@ -18524,7 +18586,7 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
<td><code>Event</code>
<td>Either the <code title=dom-media-volume><a href=#dom-media-volume>volume</a></code> attribute or the <code title=dom-media-muted><a href=#dom-media-muted>muted</a></code> attribute has changed. Fired after the relevant attribute's setter has returned.
<td>
- </table><h5 id=security-and-privacy-considerations><span class=secno>4.8.10.14 </span>Security and privacy considerations</h5>
+ </table><h5 id=security-and-privacy-considerations><span class=secno>4.8.10.15 </span>Security and privacy considerations</h5>
<p class=XXX>Talk about making sure interactive media files
(e.g. SVG) don't have access to the container DOM (XSS potential);
@@ -33878,20 +33940,20 @@ JSURL: http://ietfreport.isoc.org/all-ids/draft-hoehrmann-javascript-scheme-00.t
readonly attribute boolean <a href=#dom-navigator-online title=dom-navigator-onLine>onLine</a>;
};
-[NoInterfaceObject] interface <dfn id=navigatorbrowsingcontextabilities>NavigatorBrowsingContextAbilities</dfn> {
+[NoInterfaceObject] interface <dfn id=navigatorabilities>NavigatorAbilities</dfn> {
// content handler registration
void <a href=#dom-navigator-registerprotocolhandler title=dom-navigator-registerProtocolHandler>registerProtocolHandler</a>(in DOMString protocol, in DOMString url, in DOMString title);
void <a href=#dom-navigator-registercontenthandler title=dom-navigator-registerContentHandler>registerContentHandler</a>(in DOMString mimeType, in DOMString url, in DOMString title);
-<!-- XXX cookieEnabled geolocator javaEnabled mozIsLocallyAvailable plugins preference
- readonly attribute <span>MimeTypeArray</span> <span title="dom-navigator-mimeTypes">mimeTypes</span>;-->
- // abilities
- short <a href=#dom-navigator-canplaytype title=dom-navigator-canPlayType>canPlayType</a>(in DOMString type);
-};</pre>
+<!-- XXX cookieEnabled geolocator javaEnabled mozIsLocallyAvailable preference
+ readonly attribute <span>MimeTypeArray</span> <span title="dom-navigator-mimeTypes">mimeTypes</span>;
+ readonly attribute <span>PluginArray</span> <span title="dom-navigator-plugins">plugins</span>;
+ (the latter is used in a <video> element demo now)
+-->};</pre>
<p>Objects implementing the <code><a href=#navigator>Navigator</a></code> interface must
also implement the <a href=#navigatorid>NavigatorID</a>,
<a href=#navigatoronline>NavigatorOnLine</a>, and
- <a href=#navigatorbrowsingcontextabilities>NavigatorBrowsingContextAbilities</a> interfaces. (These
+ <a href=#navigatorabilities>NavigatorAbilities</a> interfaces. (These
interfaces are defined separately so that other specifications can
re-use parts of the <code><a href=#navigator>Navigator</a></code> interface.)</p>
@@ -34264,18 +34326,6 @@ JSURL: http://ietfreport.isoc.org/all-ids/draft-hoehrmann-javascript-scheme-00.t
-
- <h4 id=client-abilities><span class=secno>5.6.3 </span>Client abilities</h4>
-
- <p>The <dfn id=dom-navigator-canplaytype title=dom-navigator-canPlayType><code>canPlayType(<var title="">type</var>)</code></dfn> method must return 1 if <var title="">type</var> is a MIME type that the user agent is confident
- represents a <a href=#media-resource>media resource</a> that it can render if used
- in a <code><a href=#audio>audio</a></code> or <code><a href=#video>video</a></code> element, 0 if it
- cannot determine whether it could do so, and &minus;1 if it is
- confident that it would not be able to render resources of that
- type.</p>
-
-
-
<h3 id=offline><span class=secno>5.7 </span>Offline Web applications</h3>
<h4 id=introduction-0><span class=secno>5.7.1 </span>Introduction</h4>
View
165 source
@@ -17906,10 +17906,10 @@ interface <dfn>HTMLAudioElement</dfn> : <span>HTMLMediaElement</span> {
<p>The <dfn title="attr-source-type"><code>type</code></dfn>
attribute gives the type of the <span>media resource</span>, to help
the user agent determine if it can play this <span>media
- resource</span> before fetching it. Its value must be a MIME
- type. The <code title="">codecs</code> parameter may be specified
- and might be necessary to specify exactly how the resource is
- encoded. <a href="#refsRFC2046">[RFC2046]</a> <a
+ resource</span> before fetching it. If specified, its value must be
+ a MIME type. The <code title="">codecs</code> parameter may be
+ specified and might be necessary to specify exactly how the resource
+ is encoded. <a href="#refsRFC2046">[RFC2046]</a> <a
href="#refsRFC4281">[RFC4281]</a></p>
<div class="example">
@@ -18014,11 +18014,6 @@ interface <dfn>HTMLAudioElement</dfn> : <span>HTMLMediaElement</span> {
it. Its value must be a valid <a href="#mq">media query</a>. <a
href="#refsMQ">[MQ]</a></p>
- <p>Either the <code title="attr-source-type">type</code> attribute,
- the <code title="attr-source-media">media</code> attribute or both,
- must be specified, unless this is the last <code>source</code>
- element child of the parent element.</p>
-
<p>The <dfn
title="attr-source-pixelratio"><code>pixelratio</code></dfn>
attribute allows the author to specify the pixel ratio of anamorphic
@@ -18090,6 +18085,7 @@ interface <dfn>HTMLAudioElement</dfn> : <span>HTMLMediaElement</span> {
readonly attribute <span>ByteRanges</span> <span title="dom-media-bufferedBytes">bufferedBytes</span>;
readonly attribute unsigned long <span title="dom-media-totalBytes">totalBytes</span>;
void <span title="dom-media-load">load</span>();
+ DOMString <span title="dom-navigator-canPlayType">canPlayType</span>(in DOMString type);
// ready state
const unsigned short <span title="dom-media-HAVE_NOTHING">HAVE_NOTHING</span> = 0;
@@ -18184,10 +18180,6 @@ interface <dfn>HTMLAudioElement</dfn> : <span>HTMLMediaElement</span> {
task">queued</span> in this section and its subsections is the
<span>media element event task source</span>.</p>
- <p>The <code title="dom-navigator-canPlayType">canPlayType()</code>
- method can be used to probe the user agent to determine what types
- are supported.</p>
-
<h5>Error codes</h5>
@@ -18341,25 +18333,26 @@ interface <dfn>HTMLAudioElement</dfn> : <span>HTMLMediaElement</span> {
<ul>
<li>The <var title="">candidate</var> element has a <code
- title="attr-source-src">src</code> attribute</li>
+ title="attr-source-src">src</code> attribute.</li>
<li><span title="resolve a url">Resolving</span> the
<span>URL</span> given by the <var title="">candidate</var>
element's <code title="attr-source-src">src</code> attribute does
- not fail</li>
-
- <li>The <var title="">candidate</var> element has a <code
- title="attr-source-type">type</code> attribute and that
- attribute's value, when parsed as a MIME type (including any
- codecs described by the <code title="">codec</code> parameter),
- does not represent a type that the user agent knows it cannot
- render <a href="#refsRFC2046">[RFC2046]</a> <a
- href="#refsRFC4281">[RFC4281]</a></li>
-
- <li>The <var title="">candidate</var> element has a <code
- title="attr-source-media">media</code> attribute and that
- attribute's value, when processed according to the rules for <a
- href="#mq">media queries</a>, matches the current environment <a
+ not fail.</li>
+
+ <li>The <var title="">candidate</var> element either has no <code
+ title="attr-source-type">type</code> attribute, or its <code
+ title="attr-source-type">type</code> attribute's value, when
+ parsed as a MIME type (including any codecs described by the
+ <code title="">codec</code> parameter), does not represent
+ <span>a type that the user agent knows it cannot
+ render</span>.</li>
+
+ <li>The <var title="">candidate</var> element either has no <code
+ title="attr-source-media">media</code> attribute, or its <code
+ title="attr-source-media">media</code> attribute's value, when
+ processed according to the rules for <a href="#mq">media
+ queries</a>, matches the current environment. <a
href="#refsMQ">[MQ]</a></li>
</ul>
@@ -18388,6 +18381,82 @@ interface <dfn>HTMLAudioElement</dfn> : <span>HTMLMediaElement</span> {
+ <h5>Media types</h5>
+
+ <p>A <span>media resource</span> can be described in terms of its
+ <em>type</em>, specifically a MIME type, optionally with a <code
+ title="">codecs</code> parameter. <a
+ href="#refsRFC2046">[RFC2046]</a> <a
+ href="#refsRFC4281">[RFC4281]</a>.</p>
+
+ <p>Types are usually somewhat incomplete descriptions; for example
+ "<code title="">video/mpeg</code>" doesn't say anything except what
+ the container type is, and even a type like "<code
+ title="">video/mp4; codecs=&quot;avc1.42E01E,
+ mp4a.40.2&quot;</code>" doesn't include information like the actual
+ bitrate (only the maximum bitrate). Thus, given a type, a user agent
+ can often only know whether it <em>might</em> be able to play
+ media of that type (with varying levels of confidence), or whether
+ it definitely <em>cannot</em> play media of that type.</p>
+
+ <p><dfn>A type that the user agent knows it cannot render</dfn> is
+ one that describes a resource that the user agent definitely does
+ not support, for example because it doesn't recognise the container
+ type, or it doesn't support the listed codecs.</p>
+
+ <p>The <dfn title="dom-navigator-canPlayType"><code>canPlayType(<var
+ title="">type</var>)</code></dfn> method must return the string
+ "<code title="">no</code>" if <var title="">type</var> is <span>a
+ type that the user agent knows it cannot render</span>; it must
+ return "<code title="">probably</code>" if the user agent is
+ confident that the type represents a <span>media resource</span>
+ that it can render if used in with this <code>audio</code> or
+ <code>video</code> element; and it must return "<code
+ title="">maybe</code>" otherwise. Implementors are encouraged to
+ return "<code title="">maybe</code>" unless the type can be
+ confidently established as being supported or not. Generally, a user
+ agent should never return "<code title="">probably</code>" if the
+ type doesn't have a <code title="">codecs</code> parameter.</p>
+
+ <div class="example">
+
+ <p>This script tests to see if the user agent supports a
+ (fictional) new format to dynamically decide whether to use a
+ <code>video</code> element or a plugin:</p>
+
+ <pre>&lt;section id="video">
+ &lt;p>&lt;a href="playing-cats.nfv">Download video&lt;/a>&lt;/p>
+&lt;/section>
+&lt;script>
+ var videoSection = document.getElementById('video');
+ var videoElement = document.createElement('video');
+ var support = videoElement.canPlayType('video/x-new-fictional-format;codecs="kittens,bunnies"');
+ if (support != "probably" &amp;&amp; "New Fictional Video Plug-in" in navigator.plugins) {
+ // not confident of browser support
+ // but we have a plugin
+ // so use plugin instead
+ videoElement = document.createElement("embed");
+ } else if (support == "no") {
+ // no support from browser and no plugin
+ // do nothing
+ videoElement = null;
+ }
+ if (videoElement) {
+ while (videoSection.hasChildNodes())
+ videoSection.removeChild(videoSection.firstChild);
+ videoElement.setAttribute("src", "playing-cats.nfv");
+ videoSection.appendChild(videoElement);
+ }
+&lt;/script></pre>
+
+ </div>
+
+ <p class="note">To express the type of a <span>media resource</span>
+ to allow the user agent to avoid downloading resources it can't
+ render, authors can use the <code>source</code> element's <code
+ title="attr-source-type">type</code> attribute.</p>
+
+
<h5>Network states</h5>
<p>As <span title="media element">media elements</span> interact
@@ -18541,6 +18610,11 @@ interface <dfn>HTMLAudioElement</dfn> : <span>HTMLMediaElement</span> {
title="dom-media-networkState">networkState</code> to <code
title="dom-media-NETWORK_LOADING">NETWORK_LOADING</code>.</p></li>
+ <li><p>Set the <span>begun flag</span> to true and <span>queue a
+ task</span> to <span>fire a progress event</span> called <code
+ title="event-loadstart">loadstart</code> at the <span>media
+ element</span>.</p></li>
+
<li>
<p>The method must return, but these steps must continue.</p>
@@ -18554,11 +18628,6 @@ interface <dfn>HTMLAudioElement</dfn> : <span>HTMLMediaElement</span> {
<!-- SYNCHRONOUS / ASYNCHRONOUS BOUNDARY FOR EVENT DISPATCH -->
- <li><p>Set the <span>begun flag</span> to true and <span>queue a
- task</span> to <span>fire a progress event</span> called <code
- title="event-loadstart">loadstart</code> at the <span>media
- element</span>.</p></li>
-
<li>
<p><i>Candidate loop</i>: For each item in <var
@@ -19501,7 +19570,7 @@ interface <dfn>HTMLAudioElement</dfn> : <span>HTMLMediaElement</span> {
<li><p>If the fourth step above changed the value of <code
title="dom-media-paused">paused</code>, the user agent must
<span>queue a task</span> to <span>fire a simple event</span>
- called <code title="event-pause">play</code> at the
+ called <code title="event-play">play</code> at the
element.</p></li>
</ol>
@@ -38529,20 +38598,20 @@ JSURL: http://ietfreport.isoc.org/all-ids/draft-hoehrmann-javascript-scheme-00.t
readonly attribute boolean <span title="dom-navigator-onLine">onLine</span>;
};
-[NoInterfaceObject] interface <dfn>NavigatorBrowsingContextAbilities</dfn> {
+[NoInterfaceObject] interface <dfn>NavigatorAbilities</dfn> {
// content handler registration
void <span title="dom-navigator-registerProtocolHandler">registerProtocolHandler</span>(in DOMString protocol, in DOMString url, in DOMString title);
void <span title="dom-navigator-registerContentHandler">registerContentHandler</span>(in DOMString mimeType, in DOMString url, in DOMString title);
-<!-- XXX cookieEnabled geolocator javaEnabled mozIsLocallyAvailable plugins preference
- readonly attribute <span>MimeTypeArray</span> <span title="dom-navigator-mimeTypes">mimeTypes</span>;-->
- // abilities
- short <span title="dom-navigator-canPlayType">canPlayType</span>(in DOMString type);
-};</pre>
+<!-- XXX cookieEnabled geolocator javaEnabled mozIsLocallyAvailable preference
+ readonly attribute <span>MimeTypeArray</span> <span title="dom-navigator-mimeTypes">mimeTypes</span>;
+ readonly attribute <span>PluginArray</span> <span title="dom-navigator-plugins">plugins</span>;
+ (the latter is used in a <video> element demo now)
+-->};</pre>
<p>Objects implementing the <code>Navigator</code> interface must
also implement the <span>NavigatorID</span>,
<span>NavigatorOnLine</span>, and
- <span>NavigatorBrowsingContextAbilities</span> interfaces. (These
+ <span>NavigatorAbilities</span> interfaces. (These
interfaces are defined separately so that other specifications can
re-use parts of the <code>Navigator</code> interface.)</p>
@@ -38946,20 +39015,6 @@ JSURL: http://ietfreport.isoc.org/all-ids/draft-hoehrmann-javascript-scheme-00.t
-
- <h4>Client abilities</h4>
-
- <p>The <dfn title="dom-navigator-canPlayType"><code>canPlayType(<var
- title="">type</var>)</code></dfn> method must return 1 if <var
- title="">type</var> is a MIME type that the user agent is confident
- represents a <span>media resource</span> that it can render if used
- in a <code>audio</code> or <code>video</code> element, 0 if it
- cannot determine whether it could do so, and &#x2212;1 if it is
- confident that it would not be able to render resources of that
- type.</p>
-
-
-
<h3 id="offline">Offline Web applications</h3>
<h4>Introduction</h4>

0 comments on commit 911d5fa

Please sign in to comment.