Susitha
Susitha

Reputation: 3349

Cocos2d application freeze when loading sound

Load sound after 3 seconds delay. When loading this sound, animations that happening in the update function stuck for a moment(mili seconds)

- (void) onEnter
{
[super onEnter];
[self schedule:@selector(update:)];
[self performSelector:@selector(playSong) withObject:nil afterDelay:3];

}

-(void)playSong{

 soundEffectID=[[SimpleAudioEngine sharedEngine] playEffect:@"song.mp3"];
}

Sound file is only 400kb.

Upvotes: 0

Views: 86

Answers (1)

Haroon
Haroon

Reputation: 695

Please use preloadEffect Before playing it, It will avoid the jerk in the animation and frame rate.

Example : [[SimpleAudioEngine sharedEngine] preloadEffect:@"bell.wav"];

Upvotes: 1

Related Questions