How to play audio file ios
- by Camus
I am trying to play an audio file but I can get it working.
I imported the AVFoundation framework.
Here is the code:
NSString *fileName = [[NSBundle mainBundle] pathForResource:@"Alarm" ofType:@"caf"];
NSURL *url = [[NSURL alloc] initFileURLWithPath:fileName];
NSLog(@"Test: %@ ", url);
AVAudioPlayer *audioFile = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:NULL];
audioFile.delegate = self;
audioFile.volume = 1;
[audioFile play];
I am receiving an error nil string parameter
I copied the file to the supporting files folder so the file is there.
Can you guys help me?
Thanks