@@ -7,6 +7,8 @@ description: How to add closed captions to your calls
7
7
The Stream API supports adding real-time closed captions (subtitles for participants) to your calls.
8
8
This guide shows you how you can build it on top of our React Native SDK.
9
9
10
+ ![ Preview of the Closed Captions component] ( ../assets/05-ui-cookbook/21-closed-captions/cc-preview.png )
11
+
10
12
## Prerequisites
11
13
12
14
Make sure that the closed caption feature is enabled in your app's dashboard.
@@ -64,15 +66,19 @@ Once enabled, the SDK will expose the closed caption events to your application
64
66
This is how it can be used:
65
67
66
68
``` tsx
69
+ import { StyleSheet , Text , View } from ' react-native' ;
67
70
import { useCallStateHooks } from ' @stream-io/video-react-native-sdk' ;
68
71
69
72
export const ClosedCaptions = () => {
70
73
const { useCallClosedCaptions } = useCallStateHooks ();
71
74
const closedCaptions = useCallClosedCaptions ();
72
75
return (
73
76
<View style = { styles .rootContainer } >
74
- { closedCaptions .map (({ speaker_name , text }) => (
75
- <View style = { styles .closedCaptionItem } key = { ` ${speaker_name }/${text } ` } >
77
+ { closedCaptions .map (({ speaker_name , start_time , text }) => (
78
+ <View
79
+ style = { styles .closedCaptionItem }
80
+ key = { ` ${speaker_name }/${start_time } ` }
81
+ >
76
82
<Text style = { styles .speakerName } >{ speaker_name } :</Text >
77
83
<Text style = { styles .closedCaption } >{ text } </Text >
78
84
</View >
0 commit comments