Skip to content

Commit

Permalink
Update MediaPositionState WebIDL
Browse files Browse the repository at this point in the history
We make duration a required member of MediaPositionState and add default values for position and playbackRate.
duration is now unrestricted to allow Infinity, we add a special check for NaN.

We update MediaSession.setPositionState to no longer have a default value since MediaPositionState now has a required member.

Fixes w3c#303 and w3c#252.
  • Loading branch information
youennf committed Oct 24, 2023
1 parent 5d4054a commit f2a317d
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ interface MediaSession {

undefined setActionHandler(MediaSessionAction action, MediaSessionActionHandler? handler);

undefined setPositionState(optional MediaPositionState state = {});
undefined setPositionState(optional MediaPositionState state);

undefined setMicrophoneActive(boolean active);

Expand Down Expand Up @@ -879,32 +879,21 @@ interface MediaSession {

<ul>
<li>
If the <var>state</var> is an empty dictionary then clear the <a>position
state</a>.
</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>.
</li>
<li>
If the <a dict-member for="MediaPositionState">duration</a> is negative,
throw a <a exception>TypeError</a>.
If the optional argument <var>state</var> is not omitted, clear the <a>position
state</a> and abort these steps.
</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 +1193,9 @@ dictionary</h2>
<pre class="idl">

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

Expand Down

0 comments on commit f2a317d

Please sign in to comment.