Skip to content

Commit

Permalink
Update MediaPositionState WebIDL
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
youennf committed Oct 24, 2023
1 parent 5d4054a commit 00da359
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -879,32 +879,24 @@ 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>.
</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 <a dict-member for="MediaPositionState">duration</a> is negative or
<code>NaN</code>, throw a <a exception>TypeError</a>.
</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.
</li>
<li>
If the <a dict-member for="MediaPositionState">playbackRate</a> is zero
If <var>state</var>'s <a dict-member for="MediaPositionState">playbackRate</a> is zero,
throw a <a exception>TypeError</a>.
</li>
<li>
Expand Down Expand Up @@ -1204,9 +1196,9 @@ dictionary</h2>
<pre class="idl">

dictionary MediaPositionState {
double duration;
double playbackRate;
double position;
unrestricted double duration;
double playbackRate = 1.0;
double position = 0.0;
};
</pre>

Expand Down

0 comments on commit 00da359

Please sign in to comment.