|
| 1 | +--- |
| 2 | +author: cnwankwo |
| 3 | +ms.service: azure-communication-services |
| 4 | +ms.topic: include |
| 5 | +ms.date: 06/20/2023 |
| 6 | +ms.author: cnwankwo |
| 7 | +--- |
| 8 | +[!INCLUDE [Install SDK](../install-sdk/install-sdk-android.md)] |
| 9 | + |
| 10 | +Communication Services or Microsoft 365 users can call the spotlight APIs based on role type and conversation type |
| 11 | + |
| 12 | +**In a one to one call or group call scenario, the following APIs are supported for both Communication Services and Microsoft 365 users** |
| 13 | + |
| 14 | +|APIs| Organizer | Presenter | Attendee | |
| 15 | +|----------------------------------------------|--------|--------|--------| |
| 16 | +| startSpotlight | ✔️ | ✔️ | ✔️ | |
| 17 | +| stopSpotlight | ✔️ | ✔️ | ✔️ | |
| 18 | +| stopAllSpotlight | ✔️ | ✔️ | ✔️ | |
| 19 | +| getSpotlightedParticipants | ✔️ | ✔️ | ✔️ | |
| 20 | +| maxSupported | ✔️ | ✔️ | ✔️ | |
| 21 | + |
| 22 | +**For meeting scenario the following APIs are supported for both Communication Services and Microsoft 365 users** |
| 23 | + |
| 24 | +|APIs| Organizer | Presenter | Attendee | |
| 25 | +|----------------------------------------------|--------|--------|--------| |
| 26 | +| startSpotlight | ✔️ | ✔️ | | |
| 27 | +| stopSpotlight | ✔️ | ✔️ | ✔️ | |
| 28 | +| stopAllSpotlight | ✔️ | ✔️ | | |
| 29 | +| getSpotlightedParticipants | ✔️ | ✔️ | ✔️ | |
| 30 | +| maxSupported | ✔️ | ✔️ | ✔️ | |
| 31 | + |
| 32 | +Spotlight is an extended feature of the core `Call` API. You first need to import calling Features from the Calling SDK: |
| 33 | + |
| 34 | +```java |
| 35 | +import com.azure.android.communication.calling.SpotlightFeature; |
| 36 | +``` |
| 37 | + |
| 38 | +Then you can get the feature API object from the call instance: |
| 39 | + |
| 40 | +```java |
| 41 | +SpotlightCallFeature spotlightCallFeature; |
| 42 | +spotlightCallFeature = call.feature(Features.SPOTLIGHT); |
| 43 | +``` |
| 44 | +### Start spotlight for participants: |
| 45 | +Any participant in the call or meeting can be pinned. Only Microsoft 365 users who have an organizer, co-organizer or presenter role can start spotlight for other participants. This action is idempotent, trying to start spotlight on a pinned participant does nothing |
| 46 | + |
| 47 | +To use this feature, a list of participants identifiers is required |
| 48 | +```java |
| 49 | +List<CommunicationIdentifier> spotlightIdentifiers = new ArrayList<>(); |
| 50 | +CommunicationUserIdentifier acsUser = new CommunicationUserIdentifier(<USER_ID>); |
| 51 | +MicrosoftTeamsUserIdentifier teamsUser = new MicrosoftTeamsUserIdentifier(<USER_ID>); |
| 52 | +spotlightIdentifiers.add(new CommunicationUserIdentifier("<USER_ID>")); |
| 53 | +spotlightIdentifiers.add(new MicrosoftTeamsUserIdentifier("<USER_ID>")); |
| 54 | +spotlightCallFeature.StartSpotlight(spotlightIdentifiers); |
| 55 | +``` |
| 56 | +The following API can also be used to start the spotlight of participants |
| 57 | +```java |
| 58 | +CommunicationUserIdentifier acsUser = new CommunicationUserIdentifier(<USER_ID>); |
| 59 | +MicrosoftTeamsUserIdentifier teamsUser = new MicrosoftTeamsUserIdentifier(<USER_ID>); |
| 60 | +spotlightCallFeature.StartSpotlight(acsUser, teamsUser); |
| 61 | +``` |
| 62 | + |
| 63 | +### Remove spotlight from participants |
| 64 | +Any pinned participant in the call or meeting can be unpinned. Only Microsoft 365 users who have an organizer, co-organizer or presenter role can unpin other participants. This action is idempotent, trying to stop spotlight on an unpinned participant does nothing |
| 65 | + |
| 66 | +To use this feature, a list of participants identifiers is required |
| 67 | +```java |
| 68 | +List<CommunicationIdentifier> spotlightIdentifiers = new ArrayList<>(); |
| 69 | +CommunicationUserIdentifier acsUser = new CommunicationUserIdentifier(<USER_ID>); |
| 70 | +MicrosoftTeamsUserIdentifier teamsUser = new MicrosoftTeamsUserIdentifier(<USER_ID>); |
| 71 | +spotlightIdentifiers.add(new CommunicationUserIdentifier("<USER_ID>")); |
| 72 | +spotlightIdentifiers.add(new MicrosoftTeamsUserIdentifier("<USER_ID>")); |
| 73 | +spotlightCallFeature.StopSpotlight(spotlightIdentifiers); |
| 74 | +``` |
| 75 | +The following API can also be used to remove the spotlight of participants |
| 76 | +```java |
| 77 | +CommunicationUserIdentifier acsUser = new CommunicationUserIdentifier(<USER_ID>); |
| 78 | +MicrosoftTeamsUserIdentifier teamsUser = new MicrosoftTeamsUserIdentifier(<USER_ID>); |
| 79 | +spotlightCallFeature.StopSpotlight(acsUser, teamsUser); |
| 80 | +``` |
| 81 | +### Remove all spotlights |
| 82 | +All pinned participants can be unpinned using this API. Only MicrosoftTeamsUserIdentifier users who have an organizer, co-organizer or presenter role can unpin all participants. |
| 83 | +```java |
| 84 | +spotlightCallFeature.stopAllSpotlight(); |
| 85 | +``` |
| 86 | + |
| 87 | +### Handle changed states |
| 88 | +The `Spotlight` API allows you to subscribe to `SpotlightChanged` events. A `SpotlightChanged` event comes from a `call` instance and contains information about newly spotlighted participants and participants whose spotlight were stopped |
| 89 | +```java |
| 90 | +import com.azure.android.communication.calling.SpotlightedParticipant; |
| 91 | + |
| 92 | +// event : { added: SpotlightedParticipant[]; removed: SpotlightedParticipant[] } |
| 93 | +// SpotlightedParticipant = { identifier: CommunicationIdentifier } |
| 94 | +// where: |
| 95 | +// identifier: ID of participant whos spotlight state is changed |
| 96 | +void onSpotlightChanged(SpotlightChangedEvent args) { |
| 97 | + Log.i(ACTIVITY_TAG, String.format("Spotlight Changed Event")); |
| 98 | + for(SpotlightedParticipant participant: args.getadded()) { |
| 99 | + Log.i(ACTIVITY_TAG, String.format("Added ==>: %s %d", Utilities.toMRI(participant.getIdentifier()))); |
| 100 | + } |
| 101 | + |
| 102 | + for(SpotlightedParticipant participant: args.getremoved()) { |
| 103 | + Log.i(ACTIVITY_TAG, String.format("Removed ==>: %s %d", Utilities.toMRI(participant.getIdentifier()))); |
| 104 | + } |
| 105 | +} |
| 106 | +spotlightCallFeature.addOnSpotlightChangedListener(onSpotlightChanged); |
| 107 | +``` |
| 108 | + |
| 109 | +### Get all spotlighted participants: |
| 110 | +To get information about all participants that have spotlight state on current call, you can use the following API. The returned array is sorted by the order the participants were spotlighted. |
| 111 | + |
| 112 | +``` java |
| 113 | +List<SpotlightedParticipant> currentSpotlightedParticipants = spotlightCallFeature.getSpotlightedParticipants(); |
| 114 | +foreach (SpotlightedParticipant participant in currentSpotlightedParticipants) |
| 115 | +{ |
| 116 | + Trace.WriteLine("Participant " + participant.Identifier.RawId + " has spotlight"); |
| 117 | +} |
| 118 | +``` |
| 119 | + |
| 120 | +### Get the maximum supported spotlight: |
| 121 | +The following API can be used to get the maximum number of participants that can be spotlighted using the Calling SDK |
| 122 | +``` java |
| 123 | +spotlightCallFeature.maxSupported(); |
| 124 | +``` |
0 commit comments