IPhone - some audio files cannot be played

I have a list of short wav files. Two of these files cannot be played either on the simulator or on the device itself. All wav files lasting 1 second.

This is how I play files

SystemSoundID soundID;
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"sound1" ofType:@"wav"];

NSURL *fileUrl = [NSURL fileURLWithPath:filePath];
AudioServicesCreateSystemSoundID((CFURLRef)fileUrl, &soundID);
AudioServicesPlaySystemSound(soundID);

Can someone please tell me what the problem is. Thank.

PS When I browse files in Finder, files that cannot be played show the default player as QuickTime, and the rest show the default player as iTunes, if that helps anyway.

The solution suggested by Alan is to use AIFF files. To convert wav to AIFF, open the sound file in iTunes. In iTunes, select "Settings" - "General" - "Import Settings β†’ Import" using AIFF Encoder. Select a sound file, and in the "Advanced" menu, select the option "Create AIFF version"

+2
source share
2 answers

See this question. Attempting to play sound through iPhone Simulator

I had a lot more success with .aiff files.

It would be nice to know that it is AudioServicesCreateSystemSoundID that checks when a file is transferred to it.

+1
source

iPhone only supports the following codecs:

  • AMR (Adaptive Multi-Rate, Speech Codec)
  • iLBC (- , )
  • IMA/ADPCM ( IMA-4)
  • PCM
  • ΞΌLaw aLaw

WAV , , , iPhone WAV, WAV .

"afconvert", CAF ( Apple ). :.

afconvert sound1.wav sound1.caf

:

afconvert -h

. CAF iPhone.

+5

All Articles