Skip to content

Commit 2821c82

Browse files
authored
Merge pull request #188526 from chrwhit/main
Update recording-server-java.md to add new recording state events
2 parents 4b86108 + 6d5e686 commit 2821c82

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

articles/communication-services/quickstarts/voice-video-calling/includes/call-recording-samples/recording-server-java.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,32 @@ const callTransferApi = call.feature(Features.Recording);
5656
Subscribe to recording changes:
5757

5858
```JavaScript
59-
const isRecordingActiveChangedHandler = () => {
60-
console.log(callRecordingApi.isRecordingActive);
59+
const recordingStateChanged = () => {
60+
let recordings = callRecordingApi.recordings;
61+
62+
let state = SDK.RecordingState.None;
63+
if (recordings.length > 0) {
64+
state = recordings.some(r => r.state == SDK.RecordingState.Started)
65+
? SDK.RecordingState.Started
66+
: SDK.RecordingState.Paused;
67+
}
68+
69+
console.log(`RecordingState: ${state}`);
70+
}
71+
72+
const recordingsChangedHandler = (args: { added: SDK.RecordingInfo[], removed: SDK.RecordingInfo[]}) => {
73+
args.added?.forEach(a => {
74+
a.on('recordingStateChanged', recordingStateChanged);
75+
});
76+
77+
args.removed?.forEach(r => {
78+
r.off('recordingStateChanged', recordingStateChanged);
79+
});
80+
81+
recordingStateChanged();
6182
};
6283

63-
callRecordingApi.on('isRecordingActiveChanged', isRecordingActiveChangedHandler);
84+
callRecordingApi.on('recordingsUpdated', recordingsChangedHandler);
6485
```
6586
6687
Get server call ID which can be used to start/stop/pause/resume recording sessions:

0 commit comments

Comments
 (0)