如何播放AMR音频文件?

时间:2022-01-07 18:59:14

I am trying to play an .amr file.

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

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

outPut

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

1 个解决方案

#1


1  

The AMR codec was removed from iOS in version 3.2 (I think). Ah no, 4.3 (thanks, Eric D.). The only reference I ever found to this was in the dev forums (login required).

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

The strange thing is, while kAudioFormatAMR was removed in iOS 4.3, it looks like kAudioFormatAMR_WB was added to OSX 10.10 (Yosemite).

奇怪的是,虽然在iOS 4.3中删除了kAudioFormatAMR,但看起来kAudioFormatAMR_WB已添加到OSX 10.10(Yosemite)。

#1


1  

The AMR codec was removed from iOS in version 3.2 (I think). Ah no, 4.3 (thanks, Eric D.). The only reference I ever found to this was in the dev forums (login required).

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

The strange thing is, while kAudioFormatAMR was removed in iOS 4.3, it looks like kAudioFormatAMR_WB was added to OSX 10.10 (Yosemite).

奇怪的是,虽然在iOS 4.3中删除了kAudioFormatAMR,但看起来kAudioFormatAMR_WB已添加到OSX 10.10(Yosemite)。