Skip to content

Commit

Permalink
Integrate speaker_name field to JS app
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz committed Oct 4, 2024
1 parent 933cdbd commit cf645da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ call.state.closedCaptions$.subscribe((captions) =>
updateDisplayedCaptions(captions),
);

const updateDisplayedCaptions(captions: CallClosedCaption[]) {
const updateDisplayedCaptions(captions: StreamCallClosedCaption[]) {
const innerHTML = captions
.map((caption) => `<b>${caption.speaker_name}:</b> ${caption.text}`)
.join('<br>');
Expand Down
12 changes: 3 additions & 9 deletions sample-apps/client/ts-quickstart/src/closed-captions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Call, CallClosedCaption } from '@stream-io/video-client';
import { Call, StreamCallClosedCaption } from '@stream-io/video-client';

export class ClosedCaptionManager {
status: 'on' | 'off' = 'off';
Expand Down Expand Up @@ -53,7 +53,7 @@ export class ClosedCaptionManager {
this.unsubscribe?.();
}

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

this.captionContainer.innerHTML = captions
.map((caption) => {
const speaker = this.call.state.participants.find(
(p) => p.userId === caption.speaker_id,
);
const speakerName = speaker?.name || speaker?.userId;
return `<b>${speakerName}:</b> ${caption.text}`;
})
.map((caption) => `<b>${caption.speaker_name}:</b> ${caption.text}`)
.join('<br>');
}
}

0 comments on commit cf645da

Please sign in to comment.