Skip to content

Commit

Permalink
Add video conferencing actions to the spec (#269)
Browse files Browse the repository at this point in the history
* Add video conferencing actions to the spec

* Update index.bs

Co-authored-by: Tom Jenkinson <[email protected]>

* code review comments

Co-authored-by: Tom Jenkinson <[email protected]>
  • Loading branch information
steimelchrome and tjenkinson authored Apr 30, 2021
1 parent 5b5ecb5 commit 5d00a1e
Showing 1 changed file with 77 additions and 1 deletion.
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
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

0 comments on commit 5d00a1e

Please sign in to comment.