Search code examples
iosswiftavplayeravaudiosessionavcapture

AVAudioSession Changing Category Freezing AVCapture Screen


We want to continue playing your music from other apps while you capture video for our ios app. Our code is modeled like the solution the question linked below, setting up the audio session when we go into and out of our capture screen.

How do I make AVCaptureSession and AVPlayer respect AVAudioSessionCategoryAmbient?

The issue is that the app freezes up a lot when going from one of our views with an AVPlayer -> capture and then refuses to capture, but this only occurs on the iphone 5s. We confirmed it works correctly on both the 4s and 6s.

Is there something else we are missing that might need to be added to get this working? We are investigating the possibility of the AVPlayer sticking around too long and that being why our app's capture screen stops functioning correctly when switching to it.


Solution

  • The primary issue here was making sure that we paused running video before switching the audio session, changing the session, then start the video capture. This order wasn't always guaranteed before in our flow.