Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaPositionState IDL does not allow infinite duration #303

Closed
MattiasBuelens opened this issue Sep 20, 2023 · 1 comment · Fixed by #304
Closed

MediaPositionState IDL does not allow infinite duration #303

MattiasBuelens opened this issue Sep 20, 2023 · 1 comment · Fixed by #304

Comments

@MattiasBuelens
Copy link

MattiasBuelens commented Sep 20, 2023

In #202, it was suggested to allow +Infinity as a valid value for MediaPositionState.duration, to support live streams.

However, in practice, browsers do not allow this. For example, Chrome 116 throws the following error:

Uncaught TypeError: Failed to execute 'setPositionState' on 'MediaSession': Failed to read the 'duration' property from 'MediaPositionState': The provided double value is non-finite.

It appears that, during review of #210, it was suggested to change unrestricted double to double. Unfortunately, this suggestion was incorrect: unrestricted is in fact not the default for a double (see WebIDL), and browsers do check whether a regular double is finite and not NaN.

Can we fix this? I suggest something like this:

  • Change double duration to unrestricted double duration in the IDL for MediaPositionState.
  • Add the following step to setPositionState():
    • If the duration is NaN, throw a TypeError.
@youennf
Copy link
Contributor

youennf commented Sep 20, 2023

Thanks @MattiasBuelens, work might be done in #255 or as a follow-up.

youennf added a commit to youennf/mediasession that referenced this issue Oct 18, 2023
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 accept null since MediaPositionState now has a required member.

Fixes w3c#303 and w3c#252.
youennf added a commit to youennf/mediasession that referenced this issue Oct 24, 2023
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.
youennf added a commit to youennf/mediasession that referenced this issue Oct 24, 2023
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 w3c#303 and w3c#252.
youennf added a commit to youennf/mediasession that referenced this issue Oct 24, 2023
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 w3c#303 and w3c#252.
youennf added a commit that referenced this issue Jan 22, 2024
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants