hilen / TSWeChat

A WeChat alternative. Written in Swift 5.
MIT License
3.77k stars 789 forks source link

AVFAudio`-[AVAudioSession setActive:withOptions:error:]: #40

Open ChokShen opened 6 years ago

ChokShen commented 6 years ago

录音时偶现的bug,在stackoverflow找到了原因,应该是录音和播放使用的同一个AVAudioSession,导致崩溃。解决方法是在AudioPlayManager的stopPlayer()方法中加一句代码self.audioPlayer!.prepareToPlay()重置AVAudioSession: func stopPlayer() { if self.audioPlayer == nil { return } self.audioPlayer!.delegate = nil self.audioPlayer!.stop() self.audioPlayer!.prepareToPlay() //必须加上这一句,否则有可能会出现AVFAudio`-[AVAudioSession setActive:withOptions:error:]:的bug self.audioPlayer = nil UIDevice.current.isProximityMonitoringEnabled = false }

hilen commented 6 years ago

赞,可以提交一个 PR

ChokShen commented 6 years ago

Ok,最近比较忙,我的项目里集成了你的项目,做二次开发,所以发现了不少bug😂,到时候我整理一下,然后再PR。 发自我的 iPhone

在 2018年3月30日,16:35,Hilen Lai notifications@github.com 写道:

赞,可以提交一个 PR

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

hilen commented 6 years ago

感谢感谢~