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

Add video conferencing actions to the spec #269

Merged
merged 3 commits into from
Apr 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 77 additions & 1 deletion index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,18 @@ conforming IDL fragments, as described in the Web IDL specification. [[!WEBIDL]]
<dfn enum-value for=MediaSessionAction>seekto</dfn>: the action's intent
is to move the playback time to a specific time.
</li>
<li>
<dfn enum-value for=MediaSessionAction>togglemicrophone</dfn>: the action's intent
is to mute or unmute the user's microphone.
</li>
<li>
<dfn enum-value for=MediaSessionAction>togglecamera</dfn>: the action's intent
is to turn the user's active camera on or off.
</li>
<li>
<dfn enum-value for=MediaSessionAction>hangup</dfn>: the action's intent
is to end a call.
</li>
</ul>
</p>

Expand Down Expand Up @@ -541,6 +553,14 @@ conforming IDL fragments, as described in the Web IDL specification. [[!WEBIDL]]
provided for the <a>active media session</a>.
</p>

<p>
A user agent MAY implement a default handler for the <a enum-value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the default handler for those actions? Especially for hangup, would we call stop() for each MediaStreamTrack? That seems odd.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jernoble @eric-carlson May you be able to share what you're thinking of regarding default action handlers for these video conferencing actions?

Copy link

@eric-carlson eric-carlson Apr 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jernoble @eric-carlson May you be able to share what you're thinking of regarding default action handlers for these video conferencing actions?

I assume we'll do the same thing that happens now when a user clicks on the capture indicator in the Safari Chrome or menu bar - stop the capture device(s), and set the muted state of each track.

for=MediaSessionAction>togglemicrophone</a>, <a enum-value
for=MediaSessionAction>togglecamera</a>, or <a enum-value
for=MediaSessionAction>hangup</a> <a>media session actions</a> if none was
provided for the <a>active media session</a>.
</p>

<p class=note>
A page should only register a {{MediaSessionActionHandler}} for a <a>media
session action</a> when it can handle the action given that the user agent
Expand Down Expand Up @@ -708,7 +728,10 @@ enum MediaSessionAction {
"nexttrack",
"skipad",
"stop",
"seekto"
"seekto",
"togglemicrophone",
"togglecamera",
"hangup"
};

callback MediaSessionActionHandler = undefined(MediaSessionActionDetails details);
Expand All @@ -722,6 +745,10 @@ interface MediaSession {
undefined setActionHandler(MediaSessionAction action, MediaSessionActionHandler? handler);

undefined setPositionState(optional MediaPositionState state = {});

undefined setMicrophoneActive(boolean active);

undefined setCameraActive(boolean active);
};
</pre>

Expand Down Expand Up @@ -856,6 +883,20 @@ interface MediaSession {
</ul>
</p>

<p>
The <dfn method for=MediaSession>setMicrophoneActive(active)</dfn> and
<dfn method for=MediaSession>setCameraActive(active)</dfn> methods indicate to
the user agent whether the microphone and camera are currently considered by
the page to be active (e.g. if the microphone is considered "muted" by the
page since it is no longer sending audio through to a call, then the page can
invoke <code>setMicrophoneActive(false)</code>). The user agent MAY display UI
which invoke the handlers for the <a enum-value
for=MediaSessionAction>togglemicrophone</a> and <a enum-value
for=MediaSessionAction>togglecamera</a> <a>media session actions</a>, and
it is RECOMMENDED that the user agent respect the microphone and camera
states indicated by the page in this UI.
</p>

<h2 id="the-mediametadata-interface">The {{MediaMetadata}} interface</h2>

<pre class="idl">
Expand Down Expand Up @@ -1406,6 +1447,41 @@ When the <a>media session action</a> is
</pre>
</div>

<div class="example" id="example-microphone-camera-hangup">
Using video conferencing actions:
<pre class="lang-javascript">
var isMicrophoneActive = false;
var isCameraActive = false;

navigator.mediaSession.setMicrophoneActive(isMicrophoneActive);
navigator.mediaSession.setCameraActive(isCameraActive);

navigator.mediaSession.setActionHandler("togglemicrophone", function() {
if (isMicrophoneActive) {
// Mute the microphone. Implementation omitted.
} else {
// Unmute the microphone. Implementation omitted.
}
isMicrophoneActive = !isMicrophoneActive;
navigator.mediaSession.setMicrophoneActive(isMicrophoneActive);
});

navigator.mediaSession.setActionHandler("togglecamera", function() {
if (isCameraActive) {
// Disable the camera. Implementation omitted.
} else {
// Enable the camera. Implementation omitted.
}
isCameraActive = !isCameraActive;
navigator.mediaSession.setCameraActive(isCameraActive);
});

navigator.mediaSession.setActionHandler("hangup", function() {
// End the call. Implementation omitted.
});
</pre>
</div>

<h2 id="acknowledgments" class="no-num">Acknowledgments</h2>

The editors would like to thank Paul Adenot, Jake Archibald, Tab Atkins,
Expand Down