解決iOS程式耳機有聲音,外放沒聲音的問題
阿新 • • 發佈:2019-01-25
在AppDelegeate中新增如下程式碼:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. AppDelegate.instance = self let session = AVAudioSession.sharedInstance() do{ try session.setCategory(AVAudioSessionCategoryPlayAndRecord, withOptions: AVAudioSessionCategoryOptions.MixWithOthers) } catch let err as NSError { NSLog(err.description) } return true }