如何播放AMR音频文件?

Kis*_*mar 5 avaudioplayer ios swift

我正在尝试播放.amr文件.

func prepareAudio() {
    do {
        self.audioPlayer =  try AVAudioPlayer(contentsOfURL: NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("welcome", ofType: "amr")!))
        self.audioPlayer.play()           
    } catch {
        print("Error")
    }
}
Run Code Online (Sandbox Code Playgroud)

产量

ERROR:    >aq> 327: AudioConverterNew from AudioQueueNew returned 'fmt?'
io:     1 ch,   8000 Hz, Float32
client:    1 ch,   8000 Hz, 'samr' (0x00000000) 0 bits/channel, 0 bytes/packet, 2400 frames/packet, 0 bytes/frame
Run Code Online (Sandbox Code Playgroud)

Rhy*_*man 1

AMR 编解码器在 3.2 版本中已从 iOS 中删除(我认为)。啊不,4.3(谢谢,Eric D.)。我找到的唯一参考资料是在开发论坛中(需要登录)。

奇怪的是,虽然kAudioFormatAMR在 iOS 4.3 中被删除,但似乎在 OSX 10.10 (Yosemite) 中kAudioFormatAMR_WB被添加了。