Set the sound session of the application to play the currently playing sound:
try? AVAudioSession.sharedInstance().setActive(true)
try? AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryAmbient)
According to the headings AVAudioSession, it AVAudioSessionCategoryAmbientwill play sound with music, etc.
public let AVAudioSessionCategoryAmbient: String
source
share