problem - when playing a sound the animation freeze\slowing
when playing a sound the animation freeze\slowing problem.
sound size 20kb mp3.
animation size 5kb png.
also happens in other animation functions.
basically whenever i play a sound the animation slowing down or pauses, what to do ???
code:
- (void) startAnimation {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.8];
CGPoint destination = CGPointMake(152,20);
pink.center = destination;
[UIView commitAnimations];
[soundPink play];
}
- (void) initSoundResources {
soundPink = [[APlay开发者_如何学Goer alloc] initWithFile:@"ballShuffle" type:@"mp3"];
soundPink = 0.4;
}
Try the following hack:
[soundPink performSelector:@selector(play) withObject:nil afterDelay:0.001];
How large is the sound file? It's possible you're trying to load too large a sound into memory, which is slowing things down. Remember, the iPhone is not a desktop computer, so you have to consider the size of media files more carefully.
The answer may be to add a prepareToPlay can (which the play does explicitly) before the animation block so there is no stutter.
- (void) startAnimation {
[soundPink prepareToPlay];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.8];
CGPoint destination = CGPointMake(152,20);
pink.center = destination;
[UIView commitAnimations];
[soundPink play];
}
精彩评论