Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone : Does AVAudioPlayer supports .wav format?

I am going to use .wav audio files in my app.

Does AVAudioPlayer supports .wav file format ?

And which other formats supported by AVAudioPlayer ?

like image 894
Devang Avatar asked Sep 12 '11 06:09

Devang


2 Answers

Yes, AVAudioPlayer gives you the possibility to play .wav files.

It's pretty straight forward:

// in the corresponding .h file:
// @property (nonatomic, retain) AVAudioPlayer *player;

// in the .m file:
@synthesize player; // the player object

NSString *soundFilePath =
            [[NSBundle mainBundle] pathForResource: @"sound"
                                            ofType: @"wav"];

NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];

AVAudioPlayer *newPlayer =
            [[AVAudioPlayer alloc] initWithContentsOfURL: fileURL
                                                   error: nil];
[fileURL release];

self.player = newPlayer;
[newPlayer release];

[player prepareToPlay];

From: Playing Sounds Easily with the AVAudioPlayer Class

like image 86
Faizan S. Avatar answered Oct 11 '22 23:10

Faizan S.


You find complete answer on your question here : MultimediaPG

Audio Playback and Recording Formats The audio playback formats supported in iPhone OS are the following:

*AAC
*HE-AAC
*AMR (Adaptive Multi-Rate, a format for speech)
*ALAC (Apple Lossless)
*iLBC (internet Low Bitrate Codec, another format for speech)
*IMA4 (IMA/ADPCM)
*linear PCM (uncompressed)
*µ-law and a-law
*MP3 (MPEG-1 audio layer 3

The audio recording formats supported in iPhone OS are the following:

*AAC (on supported devices only)
*ALAC (Apple Lossless)
*iLBC (internet Low Bitrate Codec, for speech)
*IMA4 (IMA/ADPCM)
*linear PCM
*µ-law and a-law
like image 27
Nekto Avatar answered Oct 11 '22 21:10

Nekto