I have a UIButton that when touched plays an audio file. At the moment touching the button twice in succession plays the audio file twice instead of stopping it.
I'm looking to have the second click stop the audio file and not play a second instance. any suggestions would be very much appreciated. thanks
-(IBAction) buttonNoisePlay {
NSString *pathsoundFile = [[NSBundle mainBundle] pathForResource:@"noise" ofType:@"mp4"];
sound = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath

athsoundFile] error:NULL];
sound.delegate = self;
sound.numberOfLoops = -1;
sound.volume = 1;
if(sound == nil || sound.playing == NO) //if not playing
{
[sound play];
}
else
{
[sound stop];
}
}