-(IBAction)musiconButtonClicked:(id)sender{
NSString *path = [[NSBundle mainBundle] pathForResource:@"NextRevIt" ofType:@"mp3"];
AVAudioPlayer* audioPlayer = [[AVAudioPlayer alloc ] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[audioPlayer play];
}
-(IBAction)musicoffButtonClicked:(id)sender{
[audioPlayer stop]; <----says this is undeclared?
}
我可以使音频正常播放,但是如何制作一个停止音频的按钮?
最佳答案
将其放在interface
的.h
块中。
AVAudioPlayer* audioPlayer;
您将需要检查实例并释放它。
关于iphone - 在iPhone SDK上播放mp3吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2202607/