-
Notifications
You must be signed in to change notification settings - Fork 29
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
Should we have both onplaypause and onplay/onpause? #141
Comments
CC @avayvod @jernoble who might have opinions. IMO, exposing I think the use case is even stronger when combined with the Audio Focus API because a website could take Audio Focus without actually playing (or without the UA being entirely aware of it). In which case, they have to be able to implement their own logic. |
Thanks @mounirlamouri. I just commented on @xxyzzzq 's pull request, but for clarity, I'll reproduce it here. Both YouTube and Netflix have user-displayed playback state that does not match the element's playback state. Without an "onplaypause" command, UA controls will frequently have either no effect, or the wrong effect. So, I would either encourage adding a |
As said in the PR, the |
Aha. Okay, the argument for having a |
Do you mind elaborating? Do you mean that the page might still be playing without UA knowledge? or that the controls on the page would expose a different state? It's not entirely clear what the concern is here. |
Yes. As an example, Netflix will display a "playing" state while seeking, even though the underlying video element is paused. Without either a |
I would like to propose this: enum MediaSessionPlaybackState {
"none",
"paused",
"playing",
"stopped",
};
[Constructor(MediaSessionPlaybackInit init)]
interface MediaSessionPlayback {
readonly attribute MediaSessionPlaybackState state;
};
dictionary MediaSessionPlaybackInit {
required MediaSessionPlaybackState state;
};
partial interface MediaSession {
attribute MediaSessionPlayback? playback;
}; The idea is that we could extend this object with new data such as I think this will allow us to drop the |
Just to clarify. IIUC, the four states mean:
Is this correct? |
Yes 👍 |
So in that future world where we include
Doesn't that seem heavy-handed? Why not just make MediaSessionPlayback.state read-write? |
The idea of the playback state is that it should be updated when there are significant changes. For example, This said, I agree it is a bit too much. Another approach is to have a |
And that's fine so long as there's a single property on
The first idea is an improvement. But I don't think it's strictly necessary, especially with some spec-language like "enqueue a task to update the UA based on the new values in |
I wish it would be as simple as function updatePlaybackState(event) {
var video = event.target;
navigator.mediaSession.playback.state = video.paused ? "paused" : "playing";
} or function updatePlaybackState(event) {
var video = event.target;
navigator.mediaSession.playbackState = video.paused ? "paused" : "playing";
} |
Given that we have a need for @jernoble does that work for you? |
LGTM. 👍🏼 |
onplaypause
is actually identical withonplay
/onpause
plus a playback state boolean. The difference is that:onplaypause
, the boolean is maintained by the pageonplay
/onpause
, the boolean is decided by the UA. The UA should use its best guess or we could let the page tell the playback state through a new attribute (we need to add them).The text was updated successfully, but these errors were encountered: