Skip to content

Commit cf645da

Browse files
committed
Integrate speaker_name field to JS app
1 parent 933cdbd commit cf645da

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

packages/client/docusaurus/docs/javascript/02-guides/16-closed-captions.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ call.state.closedCaptions$.subscribe((captions) =>
5555
updateDisplayedCaptions(captions),
5656
);
5757

58-
const updateDisplayedCaptions(captions: CallClosedCaption[]) {
58+
const updateDisplayedCaptions(captions: StreamCallClosedCaption[]) {
5959
const innerHTML = captions
6060
.map((caption) => `<b>${caption.speaker_name}:</b> ${caption.text}`)
6161
.join('<br>');

sample-apps/client/ts-quickstart/src/closed-captions.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Call, CallClosedCaption } from '@stream-io/video-client';
1+
import { Call, StreamCallClosedCaption } from '@stream-io/video-client';
22

33
export class ClosedCaptionManager {
44
status: 'on' | 'off' = 'off';
@@ -53,7 +53,7 @@ export class ClosedCaptionManager {
5353
this.unsubscribe?.();
5454
}
5555

56-
private updateDisplayedCaptions(captions: CallClosedCaption[]) {
56+
private updateDisplayedCaptions(captions: StreamCallClosedCaption[]) {
5757
if (!this.captionContainer) {
5858
console.warn(
5959
'Render caption container before turning on closed captions',
@@ -62,13 +62,7 @@ export class ClosedCaptionManager {
6262
}
6363

6464
this.captionContainer.innerHTML = captions
65-
.map((caption) => {
66-
const speaker = this.call.state.participants.find(
67-
(p) => p.userId === caption.speaker_id,
68-
);
69-
const speakerName = speaker?.name || speaker?.userId;
70-
return `<b>${speakerName}:</b> ${caption.text}`;
71-
})
65+
.map((caption) => `<b>${caption.speaker_name}:</b> ${caption.text}`)
7266
.join('<br>');
7367
}
7468
}

0 commit comments

Comments
 (0)