Second call to AVAudioPlayer -> EXC_BAD_ACCESS (code posted, what did I miss?)

Posted by Jordan on Stack Overflow See other posts from Stack Overflow or by Jordan
Published on 2010-05-20T20:58:14Z Indexed on 2010/05/20 21:00 UTC
Read the original article Hit count: 321

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about avaudioplayer