|
| 1 | +--- |
| 2 | +author: karanmish |
| 3 | +title: Local recording notification for Teams |
| 4 | +titleSuffix: An Azure Communication Services tutorials document |
| 5 | +description: Show local recording notifications to users joining Teams calls or Teams meetings |
| 6 | +ms.subservice: teams-interop |
| 7 | +ms.service: azure-communication-services |
| 8 | +ms.topic: tutorial |
| 9 | +ms.date: 09/08/2021 |
| 10 | +ms.author: karanmishra |
| 11 | +--- |
| 12 | + |
| 13 | +### Local recording notification for Teams |
| 14 | + |
| 15 | +Terms of use for Azure Communication Services require developers to show notification to the users, if they are being recorded. Microsoft Teams application allows Teams users to record Teams calls and Teams meetings in the cloud and on Teams desktop app also locally. Developers can use Azure Communication Services Calling SDK to identify whether local or cloud recording has started or stopped. |
| 16 | + |
| 17 | +Azure Communication Services Calling SDK provides object `Call` to manage calls, that has dedicated features for local recording `LocalRecordingCallFeature` and cloud recording `RecordingCallFeature `. Developers need to implement both features to provide a compliant solution. |
| 18 | +You first need to import calling Features from the Calling SDK: |
| 19 | + |
| 20 | +```js |
| 21 | +import { Features} from "@azure/communication-calling"; |
| 22 | +``` |
| 23 | + |
| 24 | +Then you can get the local recording feature API object from the call instance: |
| 25 | + |
| 26 | +```js |
| 27 | +const localCallRecordingApi = call.feature(Features.LocalRecording); |
| 28 | +``` |
| 29 | + |
| 30 | +Then, to check if the call is being recorded locally, inspect the `isLocalRecordingActive` property of `localCallRecordingApi`. It returns `Boolean`. |
| 31 | + |
| 32 | +```js |
| 33 | +const isLocalRecordingActive = localCallRecordingApi.isLocalRecordingActive; |
| 34 | +``` |
| 35 | + |
| 36 | +You can also get a list of local recordings by using the `localRecordings` property of `localCallRecordingApi`. It returns `LocalRecordingInfo[]` which will have the displayName of the user and current state of the local recording. |
| 37 | + |
| 38 | +```js |
| 39 | +const recordings = localCallRecordingApi.localRecordings; |
| 40 | + |
| 41 | +recordings.forEach(r => { |
| 42 | + console.log("User: ${r.displayName}, State: ${r.state}); |
| 43 | +``` |
| 44 | +
|
| 45 | +You can subscribe to recording changes: |
| 46 | +
|
| 47 | +```js |
| 48 | +const isLocalRecordingActiveChangedHandler = () => { |
| 49 | + console.log(localCallRecordingApi.isLocalRecordingActive); |
| 50 | +}; |
| 51 | +
|
| 52 | +localCallRecordingApi.on('isLocalRecordingActiveChanged', isLocalRecordingActiveChangedHandler); |
| 53 | +``` |
| 54 | +
|
| 55 | +You can also subscribe to `localRecordingsUpdated` and get a collection of updated recordings. This event is triggered whenever there is a recording update |
| 56 | +
|
| 57 | +```js |
| 58 | +const localRecordingsUpdatedHandler = (args: { added: SDK.LocalRecordingInfo[], removed: SDK.LocalRecordingInfo[]}) => { |
| 59 | + console.log('Local recording started by: '); |
| 60 | + args.added?.forEach(a => { |
| 61 | + console.log('User: ${a.displayName}'); |
| 62 | + }); |
| 63 | +
|
| 64 | + console.log('Local recording stopped by: '); |
| 65 | + args.removed?.forEach(r => { |
| 66 | + console.log('User: ${r.displayName}); |
| 67 | + }); |
| 68 | + }; |
| 69 | +localCallRecordingApi.on('localRecordingsUpdated', localRecordingsUpdatedHandler); |
| 70 | +``` |
0 commit comments