You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/client/docusaurus/docs/javascript/02-guides/16-closed-captions.mdx
+50-74Lines changed: 50 additions & 74 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,106 +6,82 @@ description: How to add closed captions to your calls
6
6
7
7
The Stream API supports adding real-time closed captions (subtitles for participants) to your calls. This guide shows you how to implement this feature on the client side.
8
8
9
-
## Call and call type settings
9
+
## Prerequisites
10
10
11
-
The closed caption feature can be controlled with the following options:
11
+
Make sure that the closed caption feature is enabled in your app's dashboard. The closed caption feature can be set on the call type level, and the available options are:
12
12
13
13
-`available`: the feature is available for your call and can be enabled.
14
14
-`disabled`: the feature is not available for your call. In this case, it's a good idea to "hide" any UI element you have related to closed captions.
15
15
-`auto-on`: the feature is available and will be enabled automatically once the user is connected to the call.
16
16
17
-
This setting can be set on the call or call type level.
17
+
It's also possible to override the call type's default when creating a call:
You can access the most recent captions using the call state:
26
45
27
-
If closed captions are enabled for a given call, you'll receive the captions in the `call.closed_caption` events. Below, you can find an example payload:
When displaying closed captions, we should make sure that they are real-time (showing a sentence from 30 seconds ago has very little use in a conversation) and visible for enough time that participants can read them.
72
+
## Closed caption configuration
48
73
49
-
Below is an example implementation:
74
+
You can tweak the caption display logic using `updateClosedCaptionSettings` method:
50
75
51
76
```typescript
52
-
import {
53
-
Call,
54
-
CallClosedCaption,
55
-
ClosedCaptionEvent,
56
-
} from'@stream-io/video-client';
57
-
58
-
// The captions queue
59
-
let captions: (CallClosedCaption& { speaker_name?:string })[] = [];
60
-
// The maximum number of captions that can be visible on the screen
61
-
const numberOfCaptionsVisible =2;
62
-
// A single caption can stay visible on the screen for this duration
63
-
// This is the maximum duration, new captions can push a caption out of the screen sooner
Since the closed caption event contains `start_time` and `end_time` fields, you can subtract the two to know how long it took the speaker to say the caption. You can then use this duration to control how long the text is visible on the screen. This is useful to ensure the captions are as real-time as possible, but that might not leave enough time for participants to read the text.
107
-
:::
108
-
109
85
## See it in action
110
86
111
87
To see it all in action check out our TypeScript sample application on [GitHub](https://github.com/GetStream/stream-video-js/tree/main/sample-apps/client/ts-quickstart) or in [Codesandbox](https://codesandbox.io/p/sandbox/eloquent-glitter-99th3v).
0 commit comments