2017年7月29日 | Leave a comment 问题: func playWav(_ wavName : String){ let wavUrl = Bundle.main.url(forResource: wavName, withExtension: nil)! do{ try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback) try AVAudioSession.sharedInstance().setActive(true) let player = try AVAudioPlayer(contentsOf: wavUrl,fileTypeHint:"wav") //error throw player.prepareToPlay() player.play() }catch{ debugPrint(error) } } 123456789101112 func playWav(_ wavName : String){ let wavUrl = Bundle.main.url(forResource: wavName, withExtension: nil)! do{ try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback) try AVAudioSession.sharedInstance().setActive(true) let player = try AVAudioPlayer(contentsOf: wavUrl,fileTypeHint:"wav") //error throw player.prepareToPlay() player.play() }catch{ debugPrint(error) } } 解决: 改用 AVAudioPlayer(data:**) 参考: http://www.cnblogs.com/tangyuanby2/p/5676809.html