我在我的应用程序中使用 AVAudioPlayer 加载了基本的哔声。
如果我的手指没有平移我的 MKMapView,它可以很好地播放哔声。
我的哔声设置为每 2 秒播放一次。
当我开始平移地图视图并且手指没有离开屏幕时,哔声停止播放。
我记得 NSUrlConnection 在滚动表格视图时也不会触发,我认为这可能是同一个问题,但我无法弄清楚如何将我的音频播放器添加到正确的运行循环中。
我这样设置我的播放器:
-(void)setupBeep
{
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/beep.mp3", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.numberOfLoops = 0;
if(error)
{
NSLog(@"Error opening sound file: %@", [error localizedDescription]);
}
}
我正在播放这样的声音:
// plays a beeping sound
-(void)beep
{
[audioPlayer play];
}
以前有人遇到过这个问题吗?