Hey, i got a button that plays a sound when pressed. If the user presses the button again and the audio is still playing, i want it to stop and start again.
i tried some code, but it doesnt seem to stop, and i cant see why it doesnt work :s, can anyone see what is wrong here?
Code:
NSString *newAudioFile = [[NSBundle mainBundle] pathForResource:@"soundClip" ofType:@"wav"];
av = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:newAudioFile] error:NULL];
if (av.playing==YES){
[av stop];
}
if(error) {
}
av.volume=0.1;
[av play];
thanks!!