0

应用程序启动后,我按下启动按钮,它是“滞后”的,但我也将此代码用于 viewdidload 和 viewdidappear:

gombhang = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"button4" ofType:@"mp3"]];

gombha = [[AVAudioPlayer alloc] initWithContentsOfURL:gombhang error:nil];
[gombha prepareToPlay];
gombha.delegate = self;

我该如何解决这个滞后?如果我不能修复它,苹果会拒绝它吗?

4

2 回答 2

0

据我所知,Audioplayer 需要几秒钟来加载音频文件。

于 2013-01-09T13:56:45.420 回答
0
NSString *soundFile = [[NSBundle mainBundle] pathForResource:@"button4" ofType:@"wav"]; NSURL *soundFileURL = [NSURL fileURLWithPath:soundFile]; AudioServicesCreateSystemSoundID((CFURLRef) CFBridgingRetain(soundFileURL), &_MySound); AudioServicesPlaySystemSound(_MySound);

另一种方法:我制作了一个空的/静音的 0.1 秒声音文件,并在 viewdidload 中播放,这个方法在我点击开始按钮之前加载了 avaudioplayer,所以它不再滞后。

于 2013-01-21T09:04:17.670 回答