Skip to content

Commit a925cbd

Browse files
authored
Merge branch 'MicrosoftDocs:main' into main
2 parents b2e5bdd + d846d12 commit a925cbd

File tree

1 file changed

+86
-0
lines changed
  • articles/communication-services/how-tos/calling-sdk/includes/spotlight

1 file changed

+86
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
author: cnwankwo
3+
ms.service: azure-communication-services
4+
ms.topic: include
5+
ms.date: 03/01/2023
6+
ms.author: cnwankwo
7+
---
8+
[!INCLUDE [Install SDK](../install-sdk/install-sdk-web.md)]
9+
10+
Spotlight is an extended feature of the core `Call` API. You first need to import calling Features from the Calling SDK:
11+
12+
```js
13+
import { Features} from "@azure/communication-calling";
14+
```
15+
16+
Then you can get the feature API object from the call instance:
17+
18+
```js
19+
const spotLightFeature = call.feature(Features.Spotlight);
20+
```
21+
22+
### Start spotlight for current participant:
23+
To pin the video of the current/local participant, use the following code. This action is idempotent, trying to start spotlight on a pinned participant does nothing
24+
```js
25+
spotLightFeature.startSpotlight();
26+
```
27+
28+
### Spotlight specific participants
29+
Any participant in the call or meeting can be pinned. Only Microsoft 365 users who have an organizer, coorganizer or presenter role can start spotlight for other participants. This action is idempotent, trying to start spotlight on a pinned participant does nothing
30+
```js
31+
// Specify list of participants to be spotlighted
32+
CommunicationUserIdentifier acsUser = new CommunicationUserIdentifier(<USER_ID>);
33+
MicrosoftTeamsUserIdentifier teamsUser = new MicrosoftTeamsUserIdentifier(<USER_ID>)
34+
spotLightFeature.startSpotlight([acsUser, teamsUser]);
35+
```
36+
37+
### Stop spotlight for current participant:
38+
To unpin the video of the current/local participant, use the following code. This action is idempotent, trying to stop spotlight on an unpinned participant does nothing
39+
```js
40+
spotLightFeature.stopSpotlight();
41+
```
42+
43+
44+
45+
### Remove spotlight from participants
46+
Any pinned participant in the call or meeting can be unpinned. Only Microsoft 365 users who have an organizer, coorganizer or presenter role can unpin other participants. This action is idempotent, trying to stop spotlight on an unpinned participant does nothing
47+
```js
48+
// Specify list of participants to be spotlighted
49+
CommunicationUserIdentifier acsUser = new CommunicationUserIdentifier(<USER_ID>);
50+
MicrosoftTeamsUserIdentifier teamsUser = new MicrosoftTeamsUserIdentifier(<USER_ID>)
51+
spotLightFeature.stopSpotlight([acsUser, teamsUser]);
52+
```
53+
54+
### Remove all spotlights
55+
All pinned participants can be unpinned using this API. Only MicrosoftTeamsUserIdentifier users who have an organizer, coorganizer or presenter role can unpin all participants.
56+
```js
57+
spotLightFeature.stopAllSpotLight();
58+
```
59+
60+
61+
62+
### Handle changed states
63+
The `Spotlight` API allows you to subscribe to `spotlightUpdated` events. A `spotlightUpdated` event comes from a `call` instance and contains information about newly spotlighted participants and participants whose spotlight were stopped
64+
```js
65+
// event : { added: SpotlightedParticipant[]; removed: SpotlightedParticipant[] }
66+
// SpotlightedParticipant = { identifier: CommunicationIdentifier, order?: number }
67+
// where:
68+
// identifier: ID of participant whos spotlight state is changed
69+
// order: sequence of the event
70+
71+
const spotlightChangedHandler = (event) => {
72+
console.log(`Newly added spotlight state ${JSON.stringify(event.added)}`);
73+
console.log(`Newly removed spotlight state ${JSON.stringify(event.removed)}`);
74+
};
75+
spotLightFeature.on('spotlightChanged', spotlightChangedHandler);
76+
```
77+
78+
Use the following to stop receiving spotlightUpdated events
79+
```js
80+
spotLightFeature.off('spotlightChanged', spotlightChangedHandler);
81+
```
82+
### Get List of all participants currently spotlighted
83+
To get information about all participants that are spotlighted on the current call, use the following API call. It returns an array of SpotlightedParticipant
84+
```js
85+
let spotlightedParticipants = spotLightFeature.getSpotlightedParticipants();
86+
```

0 commit comments

Comments
 (0)