Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play an AMR audio file?

I am trying to play an .amr file.

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
like image 427
Kishore Kumar Avatar asked Nov 08 '22 23:11

Kishore Kumar


1 Answers

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).

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

like image 147
Rhythmic Fistman Avatar answered Nov 14 '22 21:11

Rhythmic Fistman