I'm using this code to play a different mp3 files with every call. The first time through works great. The second time crash, as indicated below.
.h
AVAudioPlayer *player;
@property (nonatomic, retain) AVAudioPlayer *player;
.m
-(void)load:(NSURL *)aFileURL {
if (aFileURL) {
AVAudioPlayer *newPlayer =
[[AVAudioPlayer alloc] initWithContentsOfURL: aFileURL
error: nil];
[aFileURL release];
self.player = newPlayer; // CRASHES HERE EXC_BAD_ACCESS with second MP3a
[newPlayer release];
[self.player prepareToPlay];
[self.player setDelegate:self];
}
}
I know I must have missed something, any ideas?