Open marcoscaceres opened 10 months ago
In WebKit, there is support for passing
null
instead as a means of clearing the position state
I don't think this is valid to pass a null dictionary member as a method argument, WebKit implementation should probably be updated.
I think Chrome is supporting both setPostionState()
and setPositionState({})
to clear the state.
But the latter throws in WebKit so maybe we could outlaw it.
If we agree on this, one possible WebIDL is:
dictionary MediaPositionState {
required double duration; // make it required
double playbackRate = 1; // add a default value
double position = 0; // add a default value
}
partial interface MediaSession {
undefined clearPositionState(); // needed?
undefined setPositionState(); // clear state, same as above
undefined setPositionState(MediaPositionState state); // set state
}
Is there a reason WebKit needs to throw on setPositionState({})
? The spec currently allows the website to send an empty MediaPositionState to clear it and only requires duration to be set for a non-empty MediaPositionState, which feels reasonable to me, and then the interface is just:
partial interface MediaSession {
undefined setPositionState(optional MediaPositionState state = {});
}
@steimelchrome, what you propose (with addition of @youennf's defaults) sounds quite reasonable to me and, as @youennf points out, it indeed does away with the need for clearPositionState()
.
We can update WebKit to match. Would you match it in Chrome?
I think the required
on duration
would prevent that from working, right? Should we remove that and then in the setPositionState()
steps insist that duration must exist if the given position state is not empty?
Yes, that would make sense, and it would be easy to enforce.
As part of https://github.com/w3c/mediasession/pull/304, when calling
setPositionState(state)
we are having to do some WebIDL/prose gymnastics in order to "clear" the position.In WebKit, there is support for passing
null
instead as a means of clearing the position state. It might be good to also add that in the spec to make clearing the position more ergonomic.