1
我有这个代码来播放声音,但第一次玩它需要花5秒钟的时间加载...可可触摸 - 加载AVAudioPlayer
我怎样才能加快速度呢?
-(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];
}