Skip to content

Commit

Permalink
[giow] (0) Introduce a fastSeek() method.
Browse files Browse the repository at this point in the history
Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=14851
Affected topics: Video and Audio

git-svn-id: http://svn.whatwg.org/webapps@7439 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Oct 8, 2012
1 parent 988764f commit 6ef1d4b
Show file tree
Hide file tree
Showing 3 changed files with 255 additions and 235 deletions.
156 changes: 81 additions & 75 deletions complete.html
Expand Up @@ -249,7 +249,7 @@

<header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
<hgroup><h1 class=allcaps>HTML</h1>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 7 October 2012</h2>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 8 October 2012</h2>
</hgroup><dl><dt><strong>Web developer edition:</strong></dt>
<dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
<dt>Multiple-page version:</dt>
Expand Down Expand Up @@ -29282,6 +29282,7 @@ <h4 id=media-elements><span class=secno>4.8.10 </span>Media elements</h4>

// playback state
attribute double <a href=#dom-media-currenttime title=dom-media-currentTime>currentTime</a>;
void <a href=#dom-media-fastseek title=dom-media-fastSeek>fastSeek</a>(double time);
readonly attribute unrestricted double <a href=#dom-media-duration title=dom-media-duration>duration</a>;
readonly attribute <span>Date</span> <a href=#dom-media-startdate title=dom-media-startDate>startDate</a>;
readonly attribute boolean <a href=#dom-media-paused title=dom-media-paused>paused</a>;
Expand Down Expand Up @@ -32043,112 +32044,116 @@ <h5 id=seeking><span class=secno>4.8.10.9 </span>Seeking</h5>

<dd>

<p>Returns a <code><a href=#timeranges>TimeRanges</a></code> object that represents the
ranges of the <a href=#media-resource>media resource</a> to which it is possible
for the user agent to seek.</p>
<p>Returns a <code><a href=#timeranges>TimeRanges</a></code> object that represents the ranges of the <a href=#media-resource>media
resource</a> to which it is possible for the user agent to seek.</p>

</dd>

<dt><var title="">media</var> . <code title=dom-media-fastSeek><a href=#dom-media-fastseek>fastSeek</a></code>( <var title="">time</var> )</dt>

<dd>

<p>Seeks to near the given <var title="">time</var> as fast as possible, trading precision for
speed. (To seek to a precise time, use the <code title=dom-media-currentTime><a href=#dom-media-currenttime>currentTime</a></code> attribute.)</p>

<p>This does nothing if the media resource has not been loaded.</p>

</dd>

</dl><div class=impl>

<p>The <dfn id=dom-media-seeking title=dom-media-seeking><code>seeking</code></dfn>
attribute must initially have the value false.</p>
<p>The <dfn id=dom-media-seeking title=dom-media-seeking><code>seeking</code></dfn> attribute must initially have the
value false.</p>

<p>When the user agent is required to <dfn id=dom-media-seek title=dom-media-seek>seek</dfn> to a particular <var title="">new
playback position</var> in the <a href=#media-resource>media resource</a>, it means
that the user agent must run the following steps. This algorithm
interacts closely with the <a href=#event-loop>event loop</a> mechanism; in
particular, it has a <a href=#synchronous-section>synchronous
section</a> (which is triggered as part of the <a href=#event-loop>event
loop</a> algorithm). Steps in that section are marked with
&#8987;.</p>
<p>The <dfn id=dom-media-fastseek title=dom-media-fastSeek><code>fastSeek()</code></dfn> method must <a href=#dom-media-seek title=dom-media-seek>seek</a> to the time given by the method's argument, with the
<i>approximate-for-speed</i> flag set.</p>

<ol><li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> is <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code>, abort these
steps.</li>
<p>When the user agent is required to <dfn id=dom-media-seek title=dom-media-seek>seek</dfn> to a particular <var title="">new playback position</var> in the <a href=#media-resource>media resource</a>, optionally with the
<i>approximate-for-speed</i> flag set, it means that the user agent must run the following steps.
This algorithm interacts closely with the <a href=#event-loop>event loop</a> mechanism; in particular, it has
a <a href=#synchronous-section>synchronous section</a> (which is triggered as part of the <a href=#event-loop>event loop</a>
algorithm). Steps in that section are marked with &#8987;.</p>

<ol><li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code>
is <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code>, abort these steps.</li>

<li><p>If the element's <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL attribute is true,
then another instance of this algorithm is already running. Abort
that other instance of the algorithm without waiting for the step
that it is running to complete.</li>
then another instance of this algorithm is already running. Abort that other instance of the
algorithm without waiting for the step that it is running to complete.</li>

<li><p>Set the <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL
attribute to true.</li>
<li><p>Set the <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL attribute to true.</li>

<li><p>If the seek was in response to a DOM method call or setting
of an IDL attribute, then continue the script. The remainder of
these steps must be run asynchronously. With the exception of the
steps marked with &#8987;, they could be aborted at any time by
another instance of this algorithm being invoked.</li>

<li><p>If the <var title="">new playback position</var> is later
than the end of the <a href=#media-resource>media resource</a>, then let it be the
end of the <a href=#media-resource>media resource</a> instead.</li>

<li><p>If the <var title="">new playback position</var> is less
than the <a href=#earliest-possible-position>earliest possible position</a>, let it be that
position instead.</li>

<li><p>If the (possibly now changed) <var title="">new playback
position</var> is not in one of the ranges given in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute, then let it
be the position in one of the ranges given in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute that is the
nearest to the <var title="">new playback position</var>. If two
positions both satisfy that constraint (i.e. the <var title="">new
playback position</var> is exactly in the middle between two ranges
in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute)
then use the position that is closest to the <a href=#current-playback-position>current playback
position</a>. If there are no ranges given in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute then set the
<code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL attribute to
false and abort these steps.</li>
<li><p>If the seek was in response to a DOM method call or setting of an IDL attribute, then
continue the script. The remainder of these steps must be run asynchronously. With the exception
of the steps marked with &#8987;, they could be aborted at any time by another instance of this
algorithm being invoked.</li>

<li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple
event</a> named <code title=event-media-seeking><a href=#event-media-seeking>seeking</a></code>
at the element.</li>
<li><p>If the <var title="">new playback position</var> is later than the end of the <a href=#media-resource>media
resource</a>, then let it be the end of the <a href=#media-resource>media resource</a> instead.</li>

<li><p>If the <var title="">new playback position</var> is less than the <a href=#earliest-possible-position>earliest possible
position</a>, let it be that position instead.</li>

<li><p>If the (possibly now changed) <var title="">new playback position</var> is not in one of
the ranges given in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute, then let it
be the position in one of the ranges given in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute that is the nearest to the <var title="">new
playback position</var>. If two positions both satisfy that constraint (i.e. the <var title="">new playback position</var> is exactly in the middle between two ranges in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute) then use the position that is closest to
the <a href=#current-playback-position>current playback position</a>. If there are no ranges given in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute then set the <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL attribute to false and abort these steps.</li>

<li>

<p>If the <i>approximate-for-speed</i> flag is set, adjust the <var title="">new playback
position</var> to a value that will allow for playback to resume promptly. If <var title="">new
playback position</var> before this step is before <a href=#current-playback-position>current playback position</a>, then
the adjusted <var title="">new playback position</var> must also be before the <a href=#current-playback-position>current
playback position</a>. Similarly, if the <var title="">new playback position</var> before
this step is after <a href=#current-playback-position>current playback position</a>, then the adjusted <var title="">new
playback position</var> must also be after the <a href=#current-playback-position>current playback position</a>.</p>

<p class=example>For example, the user agent could snap to the nearest key frame, so that it
doesn't have to spend time decoding then discarding intermediate frames before resuming
playback.</p>

</li>

<li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-seeking><a href=#event-media-seeking>seeking</a></code> at the element.</li>

<li>

<p>Set the <a href=#current-playback-position>current playback position</a> to the given
<var title="">new playback position</var>.</p>
<p>Set the <a href=#current-playback-position>current playback position</a> to the given <var title="">new playback
position</var>.</p>

<p class=note>If the <a href=#media-element>media element</a> was
<a href=#potentially-playing>potentially playing</a> immediately before it started
seeking, but seeking caused its <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute to change
to a value lower than <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code>, then a
<code title=event-media-waiting><a href=#event-media-waiting>waiting</a></code> <a href=#fire-waiting-when-waiting>will be fired</a> at the
element.</p> <!-- also, timeupdate -->
<p class=note>If the <a href=#media-element>media element</a> was <a href=#potentially-playing>potentially playing</a>
immediately before it started seeking, but seeking caused its <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute to change to a value lower than <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code>, then a <code title=event-media-waiting><a href=#event-media-waiting>waiting</a></code> <a href=#fire-waiting-when-waiting>will be
fired</a> at the element.</p> <!-- also, timeupdate -->
<!-- also, it will do the "report the controller state" thing -->

<p class=note>The <code title=dom-media-currentTime><a href=#dom-media-currenttime>currentTime</a></code> attribute does
not get updated asynchronously, as it returns the <a href=#official-playback-position>official
playback position</a>, not the <a href=#current-playback-position>current playback
position</a>.</p>
<p class=note>The <code title=dom-media-currentTime><a href=#dom-media-currenttime>currentTime</a></code> attribute does not
get updated asynchronously, as it returns the <a href=#official-playback-position>official playback position</a>, not the
<a href=#current-playback-position>current playback position</a>.</p>

</li>

<li><p>Wait until the user agent has established whether or not the
<a href=#media-data>media data</a> for the <var title="">new playback
position</var> is available, and, if it is, until it has decoded
<li><p>Wait until the user agent has established whether or not the <a href=#media-data>media data</a> for
the <var title="">new playback position</var> is available, and, if it is, until it has decoded
enough data to play back that position.</p>
<!-- at which point, it will do the "port the controller state"
thing again -->
</li>

<li><p><a href=#await-a-stable-state>Await a stable state</a>. The <a href=#synchronous-section>synchronous
section</a> consists of all the remaining steps of this
algorithm. (Steps in the <a href=#synchronous-section>synchronous section</a> are
marked with &#8987;.)</li>
<li><p><a href=#await-a-stable-state>Await a stable state</a>. The <a href=#synchronous-section>synchronous section</a> consists of all
the remaining steps of this algorithm. (Steps in the <a href=#synchronous-section>synchronous section</a> are marked
with &#8987;.)</li>

<li><p>&#8987; Set the <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL attribute to
false.</li>

<li id=seekUpdate><p>&#8987; <a href=#queue-a-task>Queue a task</a> to
<a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code> at the
element.</li>
<li id=seekUpdate><p>&#8987; <a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a>
named <code title=event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code> at the element.</li>

<li><p>&#8987; <a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple
event</a> named <code title=event-media-seeked><a href=#event-media-seeked>seeked</a></code>
at the element.</li>
<li><p>&#8987; <a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-seeked><a href=#event-media-seeked>seeked</a></code> at the element.</li>

</ol><p>The <dfn id=dom-media-seekable title=dom-media-seekable><code>seekable</code></dfn>
</ol><hr><p>The <dfn id=dom-media-seekable title=dom-media-seekable><code>seekable</code></dfn>
attribute must return a new static <a href=#normalized-timeranges-object>normalized
<code>TimeRanges</code> object</a> that represents the ranges of
the <a href=#media-resource>media resource</a>, if any, that the user agent is able
Expand Down Expand Up @@ -32182,6 +32187,7 @@ <h5 id=seeking><span class=secno>4.8.10.9 </span>Seeking</h5>

</div>


<h5 id=media-resources-with-multiple-media-tracks><span class=secno>4.8.10.10 </span>Media resources with multiple media tracks</h5>

<p>A <a href=#media-resource>media resource</a> can have multiple embedded audio
Expand Down

0 comments on commit 6ef1d4b

Please sign in to comment.