While using AVAudioPlayer .... Sound not playing at instant if i click button... and in that class i have one NSTimer which keep changing image so for that purpose i have to ring sound.
But If i will use this AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath: soundPath], &soundID);
... i am not able to hear sound in device.. cause my file is in mp3 format.
AVAudioPlayer Code:
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/slotmachine.mp3", [[NSBundle mainBundle] resourcePath]]];
NSErr开发者_运维百科or *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.numberOfLoops = -1;
[audioPlayer play];
So anyone can tell me why i am not able to use AVAudioPlayer so smoothly like System Sound does.. what is the appropriate way to integrate ?
Call [audioPlayer prepareToPlay]
well before you want to actually play the audio.
精彩评论