Playing back audio using AVAudioPlayer iOS 7

You’re having an ARC issue here. myPlayer is being cleaned up when it’s out of scope. Create a strong property, assign the AVAudioPlayer and you’re probably all set!

@property(nonatomic, strong) AVAudioPlayer *myPlayer;

...

// create new audio player
self.myPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:fileURL error:nil];
[self.myPlayer play];

Leave a Comment