我正在使用 CCVideoPlayer 在我的游戏中播放视频,但它在播放之前有一点延迟,这会导致在播放之前显示黑屏。有没有办法预加载视频或设置 CCVideoPlayer 以消除这种延迟。这是我使用它的方式,我在启动时有一个加载场景,当我的所有资源都加载完毕后,我告诉它切换到主菜单,如下所示:
[[CCDirector sharedDirector] replaceScene:[MainMenu scene]];
然后这就是我在主菜单中播放电影的方式:
+(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
我可以做些什么不同的事情来让视频立即开始播放,而不是在黑屏的情况下稍微延迟?