I have a function that is almost working. A different audio file is played depending on what page you’re on. The problem is, some of the audio files end abruptly. For example, while the audio file plays to the end on “case 1”, on “case 2” it stops about 90% in.
- (void)playAudio
{
NSURL *audioURL;
[voiceAudio release];
switch (pageNumber)
{
case 1:
audioURL = [[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:@"file1" ofType:@"aac"]];
voiceAudio = [[AVAudioPlayer alloc]
initWithContentsOfURL:audioURL error:nil];
[audioURL release];
voiceAudio.delegate = self;
[voiceAudio play];
break;
case 2:
audioURL = [[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:@"file2" ofType:@"aac"]];
voiceAudio = [[AVAudioPlayer alloc]
initWithContentsOfURL:audioURL error:nil];
[audioURL release];
voiceAudio.delegate = self;
[voiceAudio play];
break;
// And so on...
}
}
The AACs are a few minutes long. Maybe there’s a better way to go about this? AVAudioPlayer can be a bit funky. Thanks!
Edit: AVAudioPlayer is a bit unpredictable with the 64kb mono AACs I made in Adobe Soundbooth, but seems to run fine after remuxing the files to M4A. I used MP4Box to convert them using the syntax: “mp4box -add source.aac:mpeg4 -sbr -ipod target.m4a” (credit)
Reencoding to a higher bitrate (128kb) seemed to fix some, but not all, of the files as well. I didn’t thoroughly test this before I discovered remuxing.