I tried all the various options found here, even using NSData to download audio files. I tried mp3, m4a, caf files, but nothing works.
No error messages, nothing.
This is a new application using XCODE 5, iOS7.
This is what I use
- (void)playOnce:(NSString *)aSound
{
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error:nil];
[audioSession setActive:YES error:nil];
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:aSound ofType:@"m4a"];
NSURL *soundURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];
AVAudioPlayer * newAudio=[[AVAudioPlayer alloc] initWithContentsOfURL: soundURL error:nil];
[newAudio prepareToPlay];
[newAudio setNumberOfLoops:0];
[newAudio setVolume: 1];
[newAudio setDelegate: self];
[newAudio play];
}
Any help is appreciated. I have been stuck with them for too long.
Thank you in advance.
source
share