こんにちは私は次のページに私を連れて行くには、次のボタンをクリックすると、ページのターン音を再生しようとしているが、私は "再生"ボタンを押すと音楽が再生され、誰でもここで助けてください。難易度オーディオファイル
- (IBAction)next {
// This part plays the next page turn noise
NSURL *this = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/next.mp3", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:this error:&error];
[audioPlayer setDelegate:self];
audioPlayer.numberOfLoops = 0;
[audioPlayer play];
// This part takes us to the next view
Rabbana2 *rab = [[Rabbana2 alloc] initWithNibName:@"Rabbana2" bundle:nil];
[UIView beginAnimations:@"flipView" context:Nil];
[UIView setAnimationDuration:2];
[UIView setAnimationCurve:UIViewAnimationOptionCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[self.view addSubview:rab.view];
[UIView commitAnimations];
}
// This button plays the audio
- (IBAction)play {
if(clicked == 0){
clicked = 1;
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/rabbana1.wav", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
[audioPlayer setDelegate:self];
audioPlayer.numberOfLoops = 0;
[audioPlayer play];
[start setImage:[UIImage imageNamed:@"Sstop.png"] forState:UIControlStateNormal];
}
else{
[audioPlayer release];
clicked = 0;
[start setImage:[UIImage imageNamed:@"Pplay.png"] forState:UIControlStateNormal];
}
}
//If user does not do anything by the end of the sound set the button to start
- (void) audioPlayerDidFinishPlaying: (AVAudioPlayer *) player successfully: (BOOL) flag {
if (flag==YES) {
clicked = 0;
[start setImage:[UIImage imageNamed:@"Pplay.png"] forState:UIControlStateNormal];
}
out.caf私は何も見ませんあなたのコードにうっかり間違っている、あなたはどんな警告やエラーなども受け取りますか?サウンドファイルのソースのURLが正しく構築されていますか? –
[Cocoa audio issues]の複製が可能です(0120-998-504) – coneybeare
回答を得たい場合はhttp://stackoverflow.com/faqを読むことをお勧めします。重複した質問が閉じられる – coneybeare