- try to make video performance a little better

This commit is contained in:
Mark Vejvoda 2012-09-26 08:08:52 +00:00
parent 4e3d27f8c0
commit 1db56463fd
4 changed files with 20 additions and 4 deletions

View File

@ -451,7 +451,8 @@ void BattleEnd::render() {
}
else {
if(menuBackgroundVideo != NULL) {
initBackgroundVideo();
//initBackgroundVideo();
menuBackgroundVideo->RestartVideo();
}
}
}

View File

@ -177,6 +177,9 @@ void MainMenu::render() {
if(menuBackgroundVideo->isPlaying() == true) {
menuBackgroundVideo->playFrame(false);
}
else {
menuBackgroundVideo->RestartVideo();
}
}
}
state->render();

View File

@ -77,6 +77,8 @@ public:
bool isPlaying() const;
static bool hasBackEndVideoPlayer();
void RestartVideo();
};
}}

View File

@ -436,6 +436,7 @@ void VideoPlayer::init() {
if(VideoPlayer::disabled == true) {
return;
}
cleanupPlayer();
ctxPtr = new ctx();
ctxPtr->loadingCB = loadingCB;
ctxPtr->x = x;
@ -949,7 +950,7 @@ bool VideoPlayer::initPlayer() {
int progress = ((difftime(time(NULL),waitStart) / MAX_VIDEO_START_MILLISECONDS) * 100.0);
this->loadingCB->renderVideoLoading(progress);
}
SDL_Delay(1);
SDL_Delay(0);
}
}
@ -973,7 +974,7 @@ bool VideoPlayer::initPlayer() {
int progress = ((difftime(time(NULL),waitStart) / MAX_VIDEO_START_MILLISECONDS) * 100.0);
this->loadingCB->renderVideoLoading(progress);
}
SDL_Delay(1);
SDL_Delay(0);
}
}
}
@ -1309,7 +1310,8 @@ bool VideoPlayer::playFrame(bool swapBuffers) {
SDL_Event event;
/* Keys: enter (fullscreen), space (pause), escape (quit) */
while( SDL_PollEvent( &event ) ) {
//while( SDL_PollEvent( &event ) ) {
if( SDL_PollEvent( &event ) ) {
switch(event.type) {
case SDL_QUIT:
finished = true;
@ -1446,4 +1448,12 @@ bool VideoPlayer::playFrame(bool swapBuffers) {
return ctxPtr->needToQuit;
}
void VideoPlayer::RestartVideo() {
this->stop = false;
this->finished = false;
this->successLoadingLib = false;
this->initPlayer();
}
}}