I am using Twilio programmable video to connect two users in an audio chat. I want to give the user the option to record their screen during the audio session so I am using Replaykit. Everything works, except the audio on the recording cuts out as soon as Twilio starts.
Is there some conflict between the type of audio Twilio uses and Replaykit audio capture?
I experienced something like this before when trying to add sound while Twilio was active and it would cause Twilio audio to cut out as soon as another sound was played.
Edit: I've tried different ways, so I only have my latest changes, but here is the code I am using for ReplayKit. It's just standard Start, Stop, and Preview recording.
func startRecording() {
guard recorder.isAvailable else {
print("Recording not available")
return
}
recorder.isMicrophoneEnabled = true
recorder.startRecording{ [unowned self] (error) in
guard error == nil else {
print("error starting the recording")
return
}
print("Started Recording Successfully")
self.isRecording = true
}
}
func stopRecording() {
recorder.stopRecording { [unowned self] (preview, error) in
print("Stopped recording")
guard preview != nil else {
print("Preview controller not available")
return
}
let alert = UIAlertController(title: "Recording Finished", message: "Would you like to edit or delete your recording?", preferredStyle: .alert)
let deleteAction = UIAlertAction(title: "Delete", style: .destructive, handler: { (action: UIAlertAction) in
self.recorder.discardRecording(handler: { () -> Void in
print("Recording suffessfully deleted.")
})
})
let editAction = UIAlertAction(title: "Edit", style: .default, handler: { (action: UIAlertAction) -> Void in
preview?.previewControllerDelegate = self
self.present(preview!, animated: true, completion: nil)
})
alert.addAction(editAction)
alert.addAction(deleteAction)
self.present(alert, animated: true, completion: nil)
self.isRecording = false
}
}
func previewControllerDidFinish(_ previewController: RPPreviewViewController) {
dismiss(animated: true)
}
I've also tried using the new recording feature from control panel. I can capture audio from other apps, but when Twilio starts on my app, the audio on the recording goes silent and comes back when Twilio stops. This is what makes me think there is some conflict between Twilio and Replaykit, but maybe there is a way to capture it that I don't know about.
I also tried .startCapture instead of .startRecording, but I don't think I was using it right and I haven't been able to find much documentation on it.