override fun startCaptions()

in azure-communication-ui/calling/src/main/java/com/azure/android/communication/ui/calling/service/sdk/CallingSDKWrapper.kt [520:545]


    override fun startCaptions(spokenLanguage: String?): CompletableFuture<Void> {
        val resultFuture = CompletableFuture<Void>()
        val captionsFeature = call.feature(Features.CAPTIONS)
        captionsFeature.captions.whenComplete { callCaptions, throwable ->
            if (throwable != null) {
                resultFuture.completeExceptionally(throwable)
            } else {
                val captionsOptions = StartCaptionsOptions()
                if (!spokenLanguage.isNullOrEmpty()) {
                    captionsOptions.spokenLanguage = spokenLanguage
                } else if (this.compositeCaptionsOptions?.spokenLanguage?.isNotEmpty() == true) {
                    captionsOptions.spokenLanguage = this.compositeCaptionsOptions.spokenLanguage
                }
                callCaptions.startCaptions(captionsOptions)
                    .whenComplete { _, error: Throwable? ->
                        if (error != null) {
                            resultFuture.completeExceptionally(error)
                        } else {
                            callingSDKEventHandler.onCaptionsStart(callCaptions)
                            resultFuture.complete(null)
                        }
                    }
            }
        }
        return resultFuture
    }