- when intro video stops playing continue to main menu

This commit is contained in:
Mark Vejvoda 2012-05-18 19:53:01 +00:00
parent fea44117a4
commit 9fdde8c5f3
3 changed files with 50 additions and 1 deletions

View File

@ -100,6 +100,7 @@ Intro::Intro(Program *program):
mouseX = 0;
mouseY = 0;
mouse2d = 0;
exitAfterIntroVideo = false;
Renderer &renderer= Renderer::getInstance();
//renderer.init3dListMenu(NULL);
@ -509,6 +510,7 @@ Intro::Intro(Program *program):
vlcPluginsPath,
SystemFlags::VERBOSE_MODE_ENABLED);
player.PlayVideo();
exitAfterIntroVideo = true;
return;
}
}
@ -530,6 +532,10 @@ Intro::~Intro() {
}
void Intro::update() {
if(exitAfterIntroVideo == true) {
mouseUpLeft(0, 0);
return;
}
timer++;
if(timer > introTime * GameConstants::updateFps / 1000){
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

View File

@ -110,6 +110,7 @@ private:
//GLMmodel* test;
//Shared::Graphics::md5::Md5Object *md5Test;
bool exitAfterIntroVideo;
void cleanup();
void renderModelBackground();

View File

@ -73,6 +73,7 @@ struct ctx {
int width;
int height;
void *rawData;
bool isPlaying;
bool verboseEnabled;
};
@ -137,6 +138,32 @@ static void catchError(libvlc_exception_t *ex) {
}
#endif
#if defined(HAS_LIBVLC)
void trapPlayingEvent(const libvlc_event_t *evt, void *data) {
struct ctx *ctx = (struct ctx *)data;
if(ctx->verboseEnabled) printf("In [%s] Line: %d\n",__FUNCTION__,__LINE__);
ctx->isPlaying = true;
}
void trapEndReachedEvent(const libvlc_event_t *evt, void *data) {
struct ctx *ctx = (struct ctx *)data;
if(ctx->verboseEnabled) printf("In [%s] Line: %d\n",__FUNCTION__,__LINE__);
ctx->isPlaying = false;
}
void trapBufferingEvent(const libvlc_event_t *evt, void *data) {
struct ctx *ctx = (struct ctx *)data;
if(ctx->verboseEnabled) printf("In [%s] Line: %d\n",__FUNCTION__,__LINE__);
ctx->isPlaying = true;
}
void trapErrorEvent(const libvlc_event_t *evt, void *data) {
struct ctx *ctx = (struct ctx *)data;
if(ctx->verboseEnabled) printf("In [%s] Line: %d\n",__FUNCTION__,__LINE__);
ctx->isPlaying = false;
}
#endif
VideoPlayer::VideoPlayer(string filename, SDL_Surface *surface,
int width, int height,int colorBits,string pluginsPath,
bool verboseEnabled) {
@ -348,6 +375,20 @@ void VideoPlayer::PlayVideo() {
#if !defined(LIBVLC_VERSION_PRE_2) && !defined(LIBVLC_VERSION_PRE_1_1_13)
libvlc_video_set_callbacks(mp, lock, unlock, display, &ctx);
libvlc_video_set_format(mp, "RV16", width, height, this->surface->pitch);
// Get an event manager for the media player.
//libvlc_event_manager_t *eventManager = libvlc_media_player_event_manager(mp, &ex);
libvlc_event_manager_t *eventManager = libvlc_media_player_event_manager(mp);
if(eventManager) {
// libvlc_event_attach(eventManager, libvlc_MediaPlayerPlaying, (libvlc_callback_t)trapPlayingEvent, NULL, &ex);
// libvlc_event_attach(eventManager, libvlc_MediaPlayerEndReached, (libvlc_callback_t)trapEndReachedEvent, NULL, &ex);
// libvlc_event_attach(eventManager, libvlc_MediaPlayerBuffering, (libvlc_callback_t)trapBufferingEvent, NULL, &ex);
// libvlc_event_attach(eventManager, libvlc_MediaPlayerEncounteredError, (libvlc_callback_t)trapErrorEvent, NULL, &ex);
libvlc_event_attach(eventManager, libvlc_MediaPlayerPlaying, (libvlc_callback_t)trapPlayingEvent, &ctx);
libvlc_event_attach(eventManager, libvlc_MediaPlayerEndReached, (libvlc_callback_t)trapEndReachedEvent, &ctx);
libvlc_event_attach(eventManager, libvlc_MediaPlayerBuffering, (libvlc_callback_t)trapBufferingEvent, &ctx);
libvlc_event_attach(eventManager, libvlc_MediaPlayerEncounteredError, (libvlc_callback_t)trapErrorEvent, &ctx);
}
#endif
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
@ -367,7 +408,8 @@ void VideoPlayer::PlayVideo() {
*/
bool needToQuit = false;
while(successLoadingVLC == true && !done && stop == false) {
while(successLoadingVLC == true && ctx.isPlaying == true &&
done == 0 && stop == false) {
action = 0;
/* Keys: enter (fullscreen), space (pause), escape (quit) */