tags:

views:

51

answers:

1

I'm making a music app with a piano, but I need to be able to hold the sound long or short. So like if I hold a button it will start playing the sound but if I let go it stops WITH A FADE, so however long I hold the button down that is how long the sound will play (that is until the sound ends).

How do I do this in the iPhone SDK?

A: 

UIButton is a subclass of UIResponder, which has methods to tell it when a touch begins or ends - making use of those should get you what you need.

Carl Norum
Can you explain more becasue im still kinda new the code im using now to play ANY sound is... how would i set it up?- (IBAction)snare {NSString *path = [[NSBundle mainBundle] pathForResource:@"Snare" ofType:@"mp3"]; AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; theAudio.delegate = self; [theAudio play]; }
EstherBunny