ReplayKit Preview does not play Microphone Audio (but saved video does)

Hi,


I'm using some fairly simple replaykit example code available here:

https://github.com/appcoda/ReplayKitDemo

(Start and Stop recording code is below)


The issue i'm running into is that when the preview displays I don't hear the microphone recording. But after I save to the phone and view the video in photos I can hear microphone audio that was recorded. I can't seem to find out why the preview display doesn't play the microphone audio.


Any help would be appreciated. Thanks!


func startRecording() {
  
  
  guard recorder.isAvailable else {
  print("Recording is not available at this time.")
  return
  }
  
  if micToggle.isOn {
  recorder.isMicrophoneEnabled = true
  } else {
  recorder.isMicrophoneEnabled = false
  }
  
  recorder.startRecording{ [unowned self] (error) in
  
  guard error == nil else {
  print("There was an error starting the recording.")
  return
  }
  
  print("Started Recording Successfully")
  self.micToggle.isEnabled = false
  self.recordButton.backgroundColor = UIColor.red
  self.statusLabel.text = "Recording..."
  self.statusLabel.textColor = UIColor.red
  
  self.isRecording = true

  }
  
  }
  
  func stopRecording() {
  
  recorder.stopRecording { [unowned self] (preview, error) in
  print("Stopped recording")
  
  guard preview != nil else {
  print("Preview controller is 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
  
  self.viewReset()
  
  }
  
  }

Accepted Reply

This issue is resolved! The fix was so stupid. Make sure the mute ringer switch on the left is not on. The mute ringer switch mutes audio in games and apps but not in the photos and videos apps native on the phone.


I hope this saves someone else the same greif that I'd gone through for the last few days.

Replies

This issue is resolved! The fix was so stupid. Make sure the mute ringer switch on the left is not on. The mute ringer switch mutes audio in games and apps but not in the photos and videos apps native on the phone.


I hope this saves someone else the same greif that I'd gone through for the last few days.