diff --git a/source/glest_game/main/battle_end.cpp b/source/glest_game/main/battle_end.cpp index 1f4b70e6f..3eaa50709 100644 --- a/source/glest_game/main/battle_end.cpp +++ b/source/glest_game/main/battle_end.cpp @@ -451,7 +451,8 @@ void BattleEnd::render() { } else { if(menuBackgroundVideo != NULL) { - initBackgroundVideo(); + //initBackgroundVideo(); + menuBackgroundVideo->RestartVideo(); } } } diff --git a/source/glest_game/menu/main_menu.cpp b/source/glest_game/menu/main_menu.cpp index d6f883f37..35a431e0f 100644 --- a/source/glest_game/menu/main_menu.cpp +++ b/source/glest_game/menu/main_menu.cpp @@ -177,6 +177,9 @@ void MainMenu::render() { if(menuBackgroundVideo->isPlaying() == true) { menuBackgroundVideo->playFrame(false); } + else { + menuBackgroundVideo->RestartVideo(); + } } } state->render(); diff --git a/source/shared_lib/include/graphics/video_player.h b/source/shared_lib/include/graphics/video_player.h index 3a206c119..4110520d6 100644 --- a/source/shared_lib/include/graphics/video_player.h +++ b/source/shared_lib/include/graphics/video_player.h @@ -77,6 +77,8 @@ public: bool isPlaying() const; static bool hasBackEndVideoPlayer(); + + void RestartVideo(); }; }} diff --git a/source/shared_lib/sources/graphics/video_player.cpp b/source/shared_lib/sources/graphics/video_player.cpp index f7c5b4c29..ba214a481 100644 --- a/source/shared_lib/sources/graphics/video_player.cpp +++ b/source/shared_lib/sources/graphics/video_player.cpp @@ -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(); +} + }}