IPhone: Does AVAudioPlayer support WAV format?

I will use .wav sound files in my application.

Does AVAudioPlayerthe file format support .wav?

And what other formats are supported AVAudioPlayer?

+5
source share
2 answers

Yes, AVAudioPlayerit gives you the ability to play files .wav.

This is 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: Easily play sounds using the AVAudioPlayer class

+3
source

You will find the complete answer to your question here: MultimediaPG

, iPhone OS, :

*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

, iPhone OS, :

*AAC (on supported devices only)
*ALAC (Apple Lossless)
*iLBC (internet Low Bitrate Codec, for speech)
*IMA4 (IMA/ADPCM)
*linear PCM
*ยต-law and a-law
0

All Articles