Reputation: 2897
the code I'm using to play the sound is this:
NSString *soundFilePath = [NSString stringWithFormat:@"%@/%@.m4a", [[NSBundle mainBundle] resourcePath],currentSound.soundNameID];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
player.numberOfLoops = 0;
[player play];
I'm trying to play the sound but it wont play. my file is a m4a
type.
Upvotes: 0
Views: 85
Reputation: 511
if soundFileURL is OK, then I think the problem is that player is released before playing sound, declare player in header file.
Upvotes: 1
Reputation: 41642
Add abn assert after each object creation to look for a nil object. Also don't do this in the button selector, put it into a block you dispatch to the main queue.
Upvotes: 0