I am using CCVideoPlayer to play a video in my game but it has a slight delay before it plays which causes a black screen to show before it plays. Is there some way to preload the video or set up CCVideoPlayer in a way that does away with this delay. Here is how I am using it, I have a loading scene upon start up and when all my resources are loaded I tell it to switch to the main menu like so:
[[CCDirector sharedDirector] replaceScene:[MainMenu scene]];
And then this is how I am playing the movie in the main menu:
+(CCScene *) scene
{
CCScene *scene = [CCScene node];
MainMenu *layer = [MainMenu node];
[scene addChild: layer];
return scene;
}
- (id) init {
if( (self=[super init])) {
[CCVideoPlayer setDelegate: self];
}
return self;
}
- (void)onEnter{
[self playVideo];
}
[super onEnter];
}
-(void)onExit{
[super onExit];
}
- (void) playVideo {
[CCVideoPlayer playMovieWithFile: @"MenuBuild.m4v"];
}
- (void) movieStartsPlaying {
[[CCDirector sharedDirector] stopAnimation];
}
- (void) moviePlaybackFinished
{
[[CCDirector sharedDirector] startAnimation];
}
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
// Updates orientation of CCVideoPlayer. Called from SharedSources/RootViewController.m
- (void) updateOrientationWithOrientation: (UIDeviceOrientation) newOrientation
{
[CCVideoPlayer updateOrientationWithOrientation:newOrientation ];
}
#endif
- (void) dealloc {
[CCVideoPlayer setDelegate: nil];
[super dealloc];
}
@end
Is there something different that I could do to have the video instantly start playing instead of a slight delay with a black screen?