Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play PCM data/buffer just using AVAudioPlayer or AVPlayer?

How can i play PCM data/buffer just using AVAudioPlayer or AVPlayer ? I know, i can play PCM data/buffer using AudioUnit/AudioQueue by feeding the data into play callback method. But don't want to do this.

I have searched on google a lot but couldn't find any helpful answer or any sample code to do this. Any help would be highly appreciated.

like image 409
Partho Biswas Avatar asked Jan 29 '15 19:01

Partho Biswas


1 Answers

I am answering my own question if it helps someone else. After few days of tireless trying, at last i have got it working. Though in a separate way. I have added a wav header info on top of RAW PCM data and saved a file with .wav extension. Then just play the file using AVAudioPlayer or AVPlayer. Here you will get full sample code on How to add playable(such as wav,wmv) header with PCM data/buffer in iOS ou.

like image 194
Partho Biswas Avatar answered Sep 29 '22 12:09

Partho Biswas