ボタンを押すと音を鳴らすテーブルビューセルにボタンを配置し、ボタンを押すと音を止めます。しかし、別のセルの別のボタンを押しても、別のサウンドが再生されている間は別のサウンドが再生されません。別のテーブルセルで別のボタンを押すと、再生音が止まることを願っています。
これが私のコードです
.h ファイル
これを @interface ブラケット AVAudioPlayer *talkSound; に入力します。
.m
NSString *myExamplePath = [[NSBundle mainBundle] pathForResource:@"kumusta" ofType:@"m4a"];
if (talkSound.playing) {
[talkSound stop];
[talkSound release];
}
talkSound =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:myExamplePath] error:NULL];
talkSound.delegate = self; /*with this here it says theres no delegate so i go an add AVAudioPlayerDelegate and i get tons of errors of connot find protocol declaration*/
[talkSound play];