iosswiftswift3avaudioplayerextaudiofile

AVAudioPlayer cannot play Audio (.wav) file written using ExtAudioFileWriteAsync


I used ExtAudioFileWriteAsync to write the recorded audio using RemoteIO into a .wav file. AVAudioPlayer is not playing the saved audio file. The audio file plays only on VLC media player but not in QuickTime or any other media players.

var player = AVAudioPlayer(contentsOf: audioFileURL)
player.play()

Some basic details of audio file: enter image description here

Kindly suggest a solution.


Solution

  • After wasting 2 days, I have found the issue is with not flushing the audio data using ExtAudioFileDispose call. As the final audio data was not flushed, the wav file was partial and corrupted. It was only played in VLC player and not any other players. After using the ExtAudioFileDispose, the Audio plays well with AVAudioPlayer also.

    result = ExtAudioFileDispose(self.extAudioFileRef!)