大佬教程收集整理的这篇文章主要介绍了ios – 播放mp3 / wav声音会导致异常,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
例外情况来自于
com.apple.coreaudio.AQClient (18): breakpoint 2.2
从
libc++abi.dylib`__cxa_throw:
这就是我初始化AVAudioPlayer的方式
guard let path = Bundle.main.path(forresource: file,ofType: typE) else { return nil } guard let url = URL(String: path) else { return nil } try? AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryAmbient,with: .mixWithOthers) try? AVAudioSession.sharedInstance().setActive(true) return try? AVAudioPlayer(contentsOf: url)
我正在播放来自异步全局调度队列的声音,播放声音的方法包含
self.sound?.prepareToPlay() self.sound?.play()
最初该文件是一个wav文件,所以我将其转换为mp3文件,但没有帮助.我也使用了完全不同的声音,它会产生相同的异常.
虽然Rollbar使用这样的stracktrace报告SIGSEGV错误,但异常本身不会使模拟器崩溃:
libpassFAudio.dylib在0x27c1c000中
使用的音频类:
import AVFoundation import Foundation class Audiotools { var sound: AVAudioPlayer? let dispatchQueue = DispatchQueue(label: "audio") static var shared: Audiotools = { let manager = Audiotools() return manager }() init() { self.sound = configureplayer(withFile: Files.sound.name,type: Files.sound.extension) } func configureplayer(withFile file: String,type: String) -> AVAudioPlayer? { guard let path = Bundle.main.path(forresource: file,ofType: typE) else { return nil } guard let url = URL(String: path) else { return nil } try? AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryAmbient,with: .mixWithOthers) try? AVAudioSession.sharedInstance().setActive(true) return try? AVAudioPlayer(contentsOf: url) } func playSound() { self.dispatchQueue.async { self.sound?.prepareToPlay() self.sound?.play() } } }
其他Rollbar报告:
SIGSEGV: Application terminated libsystem_platform.dylib in _platform_memmove AudioTool@L_675_38@ in Cached_Datasource::readFromHeaderCache(long long,unsigned int,void*,unsigned int*) AudioTool@L_675_38@ in Cached_Datasource::readBytes(unsigned short,long long,unsigned int*) AudioTool@L_675_38@ in AudioFiLeobject::readBytes(unsigned char,unsigned int*,void*) AudioTool@L_675_38@ in AudioFiLeobject::readPacketDataVBR(unsigned char,AudioStreamPacketDescription*,void*) AudioTool@L_675_38@ in AudioFileReadPacketData AVFAudio in AVAudioPlayerCpp::AQOutputCallBACkCore(OpaqueAudioQueue*,AudioQueueBuffer*) AVFAudio in AVAudioPlayerCpp::prepareToPlayQueue() AVFAudio in AVAudioPlayerCpp::playQueue(Audiotimestamp const*) AVFAudio in AVAudioPlayerCpp::play() AVFAudio in -[AVAudioPlayer play]
还有其他人有过这种问题吗?
以上是大佬教程为你收集整理的ios – 播放mp3 / wav声音会导致异常全部内容,希望文章能够帮你解决ios – 播放mp3 / wav声音会导致异常所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。