【发布时间】:2010-08-19 17:09:14
【问题描述】:
我有这段代码可以播放声音,但第一次播放时需要 5 秒才能加载...
如何加快速度?
-(IBAction)playSound{ //play the cricket noise
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"Cricket_Sound" ofType:@"mp3"];
audioPlayer =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:soundPath] error:NULL];
audioPlayer.delegate = self;
[audioPlayer prepareToPlay];
audioPlayer.numberOfLoops = 0;
[audioPlayer play];
}
【问题讨论】:
标签: cocoa-touch avaudioplayer preloading