Skip to content

Commit a6f4be2

Browse files
authored
Add files via upload
add iOS how-to guide
1 parent 68735a3 commit a6f4be2

File tree

1 file changed

+164
-0
lines changed
  • articles/communication-services/how-tos/calling-sdk/includes/closed-captions

1 file changed

+164
-0
lines changed
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
---
2+
title: include file
3+
description: iOS how-to guide for enabling Closed captions during a call .
4+
author: Kunaal
5+
ms.service: azure-communication-services
6+
ms.subservice: calling
7+
ms.topic: include
8+
ms.topic: include file
9+
ms.date: 03/20/20223
10+
ms.author: kpunjabi
11+
---
12+
13+
## Prerequisites
14+
- Azure account with an active subscription, for details see [Create an account for free.](https://azure.microsoft.com/free/)
15+
- Azure Communication Services resource. See [Create an Azure Communication Services resource](../../../quickstarts/create-communication-resource.md?tabs=windows&pivots=platform-azp). Save the connection string for this resource.
16+
- An app with voice and video calling, refer to our [Voice](../../quickstarts/voice-video-calling/getting-started-with-calling.md) and [Video](../../quickstarts/voice-video-calling/get-started-with-video-calling.md) calling quickstarts.
17+
- [Access tokesn](../../quickstarts/manage-teams-identity.md) for Microsoft 365 users.
18+
- [Access tokesn](../../quickstarts/identity/access-tokens.md) for External identity users.
19+
- For Translated captions you will need to have a [Teams premium](https://www.microsoft.com/en-us/microsoft-teams/premium#tabx93f55452286a4264a2778ef8902fb81a) license.
20+
21+
>[!NOTE]
22+
>Please note that you will need to have a voice calling app using ACS calling SDKs to access the closed captions feature that is described in the QuickStart below.
23+
24+
## Models
25+
| Name | Description |
26+
|------|-------------|
27+
| TeamsCaptionsCallFeature | API for TeamsCall captions |
28+
| StartCaptionOptions | Closed caption options like spoken language |
29+
| TeamsCaptionsCallFeatureDelegate | Delegate for events |
30+
| TeamsCaptionsInfo | Data object received for each didReceiveCaptions event |
31+
32+
## Get closed captions feature
33+
34+
### External Identity users
35+
36+
If you're building an application that allows ACS users to join a Teams meeting
37+
38+
``` swift
39+
if let call = self.call { @State var captionsCallFeature = call.feature(Features.teamsCaptions) }
40+
```
41+
42+
### Microsoft 365 users
43+
44+
``` swift
45+
if let teamsCall = self.teamsCall { @State var captionsCallFeature = call.feature(Features.teamsCaptions) }
46+
```
47+
48+
## Subscribe to listeners
49+
50+
### Add a listener to receive captions active/inactive status and data received
51+
52+
```swift
53+
extension CallObserver: TeamsCaptionsCallFeatureDelegate {
54+
// Add a listener to receive captions active/inactive status
55+
public func teamsCaptionsCallFeature(_ teamsCaptionsFeature: TeamsCaptionsCallFeature, didChangeCaptionsActiveState args: PropertyChangedEventArgs) {
56+
if(captionsCallFeature.isCaptionsFeatureActive) {
57+
58+
}
59+
}
60+
61+
// Add listener for captions data received
62+
public func teamsCaptionsCallFeature(_ teamsCaptionsFeature: TeamsCaptionsCallFeature, didReceiveCaptions: TeamsCaptionsInfo) {
63+
64+
}
65+
}
66+
67+
teamsCaptionsFeature.delegate = self.callObserver
68+
```
69+
70+
## Start captions
71+
72+
Once you've got all your listeners setup you can now start captions.
73+
74+
``` swift
75+
func startCaptions() {
76+
guard let captionsCallFeature = captionsCallFeature else {
77+
return
78+
}
79+
let startCaptionsOptions = StartCaptionsOptions()
80+
startCaptionsOptions.spokenLanguage = "en-us"
81+
captionsCallFeature.startCaptions(startCaptionsOptions: startCaptionsOptions, completionHandler: { (error) in
82+
if error != nil {
83+
84+
}
85+
})
86+
}
87+
```
88+
89+
## Stop captions
90+
91+
``` swift
92+
func stopCaptions() {
93+
captionsCallFeature.stopCaptions(completionHandler: { (error) in
94+
if error != nil {
95+
96+
}
97+
})
98+
}
99+
```
100+
101+
## Remove caption received listener
102+
103+
``` swift
104+
captionsCallFeature?.delegate = nil
105+
```
106+
107+
## Spoken language support
108+
109+
### Get list of supported spoken languages
110+
Get a list of supported spoken languages that your users can select from when enabling closed captions.
111+
112+
``` swift
113+
// bcp 47 formatted language code
114+
let spokenLanguage : String = "en-us"
115+
for language in captionsCallFeature?.supportedSpokenLanguages ?? [] {
116+
// choose required language
117+
spokenLanguage = language
118+
}
119+
```
120+
121+
### Set spoken language
122+
When the user selects the spoken language, your app can set the spoken language that it expects captions to be generated from.
123+
124+
``` swift
125+
func setSpokenLanguage() {
126+
guard let captionsCallFeature = self.captionsCallFeature else {
127+
return
128+
}
129+
130+
captionsCallFeature.set(spokenLanguage: spokenLanguage, completionHandler: { (error) in
131+
if let error = error {
132+
}
133+
})
134+
}
135+
```
136+
137+
## Caption language support
138+
139+
### Get supported caption language
140+
141+
If your organization has an active Teams premium license, then your ACS users can enable translated captions as long as the organizer of the meeting has a Teams premium license. As for users with Microsoft 365 identities this check will be done against their own user account if they meeting organizer doesn't have a Teams premium license.
142+
143+
``` swift
144+
// ISO 639-1 formatted language code
145+
let captionLanguage : String = "en"
146+
for language in captionsCallFeature?.supportedCaptionLanguages ?? [] {
147+
// choose required language
148+
captionLanguage = language
149+
}
150+
```
151+
### Set caption language
152+
153+
``` swift
154+
func setCaptionLanguage() {
155+
guard let captionsCallFeature = self.captionsCallFeature else {
156+
return
157+
}
158+
159+
captionsCallFeature.set(captionLanguage: captionLanguage, completionHandler: { (error) in
160+
if let error = error {
161+
}
162+
})
163+
}
164+
```

0 commit comments

Comments
 (0)