I am making a soundboard app and i am using sounds with over 30sec duration. I am playing the sound by connecting in IB my action with a “touch down” event, however the sound keeps playing once started. I connected in the some button a “touch cancel” & “touch up outside” event that is supposed to stop the sound but for some reason it doesn’t.
Can anybody provide a solution to my problem?
—Edit—
Here is my code:
-(IBAction)playSound:(id)sender {
NSString *soundFile;
soundFile = [[NSBundle mainBundle] pathForResource:@"testSound" ofType:@"mp3"];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:soundFile] error:nil];
audioPlayer.volume = volumeSlider.value;
audioPlayer.numberOfLoops = -1;
[audioPlayer prepareToPlay];
[audioPlayer play];
}
-(IBAction)stopSound:(id)sender {
[audioPlayer stop];
}
“Touch up outside” refers to when the button is pressed down and the user’s finger moves and lifts outside of the control.
It sounds like you’re looking for the “Touch up inside” event.
However, just to be sure, you should post the code you’re using to start and stop the sound.