I have this code:
NSString *path = [NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], @"change.mp3"]; NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO]; change = [[AVAudioPlayer alloc] initWithContentsOfURL:filePath error:nil]; [change prepareToPlay];
I write in this code in viewdidload; now with the button I start this sound, but if I press the same button, I want to stop this sound and restart the sound; I try this code inside IBAction, but it does not work.
[change stop]; [change prepareToPlay]; [change play];
What can I do?
source share