Skip to content

Commit

Permalink
Update MediaPositionState WebIDL (#304)
Browse files Browse the repository at this point in the history
* Update MediaPositionState WebIDL

We add default values for position and playbackRate.
duration is now unrestricted to allow Infinity and we add a special check for NaN.
We do not make duration required so that MediaSession.setPositionState can still take an optional state argument.

Fixes #303 and #252.

Co-authored-by: Marcos Cáceres <[email protected]>
  • Loading branch information
youennf and marcoscaceres authored Jan 22, 2024
1 parent d07ef18 commit 42221de
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -876,32 +876,30 @@ interface MediaSession {

<ul>
<li>
If the <var>state</var> is an empty dictionary then clear the <a>position
state</a>.
If <var>state</var> is an empty dictionary, clear the <a>position state</a>
and abort these steps.
</li>
<li>
If the <a dict-member for="MediaPositionState">duration</a> is not present
or its value is null, throw a <a exception>TypeError</a>.
If <var>state</var>'s <a dict-member for="MediaPositionState">duration</a> is not
present, throw a <a exception>TypeError</a>.
</li>
<li>
If the <a dict-member for="MediaPositionState">duration</a> is negative,
throw a <a exception>TypeError</a>.
If <var>state</var>'s {{MediaPositionState/duration}} is negative or
<code>NaN</code>, throw a <a exception>TypeError</a>.
</li>
<li>
If the <a dict-member for="MediaPositionState">position</a> is not present
or its value is null, set it to zero.
If <var>state</var>'s {{MediaPositionState/position}} is not present, set it to zero.
</li>
<li>
If the <a dict-member for="MediaPositionState">position</a> is negative or
If <var>state</var>'s <a dict-member for="MediaPositionState">position</a> is negative or
greater than <a dict-member for="MediaPositionState">duration</a>, throw a
<a exception>TypeError</a>.
</li>
<li>
If the <a dict-member for="MediaPositionState">playbackRate</a> is not
present or its value is null, set it to 1.0.
If <var>state</var>'s <a dict-member for="MediaPositionState">playbackRate</a> is not present, set it to 1.0.
</li>
<li>
If the <a dict-member for="MediaPositionState">playbackRate</a> is zero
If <var>state</var>'s {{MediaPositionState/playbackRate}} is zero,
throw a <a exception>TypeError</a>.
</li>
<li>
Expand Down Expand Up @@ -1201,7 +1199,7 @@ dictionary</h2>
<pre class="idl">

dictionary MediaPositionState {
double duration;
unrestricted double duration;
double playbackRate;
double position;
};
Expand Down

0 comments on commit 42221de

Please sign in to comment.