AVI Intro Problem: easy solution?
by Alessandro Loureiro · in Torque Game Engine · 10/04/2005 (6:34 pm) · 6 replies
Hi Guys. Now i'm having trouble with the AVI system player on Torque.
Straight to procedures: Using John's guiAviBitmapCtrl.cc and guiAviBitmapCtrl.h (a resource of Torque forum) i've added the files to the correct engine's subdirectories, openned Visual C++ and "Cleared" the project before recompilyng it, recompiled the engine, then i added:
...in starter.fps/client/ui/Startup.gui :
...in starter.fps/client/ui/MoviePlayer.cs :
in... engine/gui/guiAviBitmapCtrl.cc
This one is just to not loose windows focus AFTER the avi played normally. Inside loadStartup of Startup.gui there's a "schedule" running. Well, normally it would detect WHEN the avi ended after every cycle of the scheduler (i believe...), but all it does is end the avi and jump to Main window right on the first cycle.
So, i have to change from 5000 (its about 4-5 seconds of avi) to 65000 (almost a minute, that's how long is my AVI). That makes him stop the avi when the same ended already... IF no one pressed anything!
So, what happens is: The Intro avi will play normaly until it's end, and then change to the main screen, beautifully... but if i click the keyboard or the mouse, windows go black or loose focus,returning to the desktop. The Main window don't load at this time and so it's just a black "hall-of-mirrors" with a mouse pointer (just like when you are re-lightining a mission scenario). It will stay like that until the "avi time" on the scheduler had run out...
I think this should have some simple solution, but i'm no programmer. one way would be to add a line like this:
Of course, i didn't found the DAMN mouse/keyboard instructions nowhere...
Or maybe... DETECT when the AVI stops playing with the onMovieClosed return from the "S32 GuiAviBitmapCtrl::movieClose()" C++ instruction... but i didn't manage to make it work.
Anyone had a similar problem? Any help will be deeply appreciated...
Thanks in advance.
Straight to procedures: Using John's guiAviBitmapCtrl.cc and guiAviBitmapCtrl.h (a resource of Torque forum) i've added the files to the correct engine's subdirectories, openned Visual C++ and "Cleared" the project before recompilyng it, recompiled the engine, then i added:
...in starter.fps/client/ui/Startup.gui :
function loadStartup()
{
StartupGui.done = true;
echo ("Intro Video");
exec("starter.fps/client/ui/movieplayer.cs");
schedule(5000, 0, checkStartupDone );
}and:...in starter.fps/client/ui/MoviePlayer.cs :
new GuiControlProfile (IntroProfile)
{
opaque = false;
fillColor = "0 0 0";
fillColorHL = "0 0 0";
fillColorNA = "0 0 0";
tab = true;
canKeyFocus = true;
};
// Create the GuiAviBitmapCtrl
new GuiAviBitmapCtrl(IntroGui)
{
profile = "IntroProfile";
horizSizing = "width";
vertSizing = "height";
position = "0 0";
extent = "640 480";
minExtent = "8 8";
visible = "1";
variable = "";
helpTag = "0";
useVariable = "1";
aviFileName = "starter.fps/client/ui/INTRO.avi";
setFirstResponder = "1";
letterBox = true;
swapRB = true;
};
Canvas.pushDialog(IntroGui);
Canvas.hideCursor();
IntroGui.play();
schedule(100, 0, checkIntroDone);
function checkIntroDone()
{
if (IntroGui.done)
{
Canvas.popDialog(IntroGui);
Canvas.showCursor();
IntroGui.delete();
IntroProfile.delete();
}
else
schedule(100, 0, checkIntroDone);
} and then, tryied to play my Intro.avi... started nicely, but ended two seconds after start and even lost the correct window focus... checking the resource again, Eric Lafrance added a C++ code inside the .h file:in... engine/gui/guiAviBitmapCtrl.cc
// Close movie stream
S32 GuiAviBitmapCtrl::movieClose()
{
movieStop();
if (g_pVideoWindow)
{
g_pVideoWindow->put_Owner(NULL);
g_pVideoWindow->put_Visible(OAFALSE);
SetForegroundWindow(mWindow); //Eric
}
// notify the script that the movie was closed
Con::executef(this, 1, "onMovieClosed");
return MOVERR_OK;
}This one is just to not loose windows focus AFTER the avi played normally. Inside loadStartup of Startup.gui there's a "schedule" running. Well, normally it would detect WHEN the avi ended after every cycle of the scheduler (i believe...), but all it does is end the avi and jump to Main window right on the first cycle.
So, i have to change from 5000 (its about 4-5 seconds of avi) to 65000 (almost a minute, that's how long is my AVI). That makes him stop the avi when the same ended already... IF no one pressed anything!
schedule(65000, 0, checkStartupDone );
So, what happens is: The Intro avi will play normaly until it's end, and then change to the main screen, beautifully... but if i click the keyboard or the mouse, windows go black or loose focus,returning to the desktop. The Main window don't load at this time and so it's just a black "hall-of-mirrors" with a mouse pointer (just like when you are re-lightining a mission scenario). It will stay like that until the "avi time" on the scheduler had run out...
I think this should have some simple solution, but i'm no programmer. one way would be to add a line like this:
function detect_avibreakup()
{
if(the_mouse_or_keyboard_beenpressed==1)
{
checkStartupDone;
}
}Of course, i didn't found the DAMN mouse/keyboard instructions nowhere...
Or maybe... DETECT when the AVI stops playing with the onMovieClosed return from the "S32 GuiAviBitmapCtrl::movieClose()" C++ instruction... but i didn't manage to make it work.
Anyone had a similar problem? Any help will be deeply appreciated...
Thanks in advance.
#2
After much struggle of a non-programmer, i mean... :S
Well, thing is, that ::click() instructions is defined only inside the GuiFadeinBitmapCtrl. The avi control accepts other, however... ::onMovieStopped() !!! This instruction, unfortunatelly, will run endlessly so i have to implement some variable filters in the instructions.
In other words, to play a .AVI intro in your game, you have to remake the script like that:
in... client/ui/Startup.Gui :
just to be sure, here goes the new MoviePlayer.cs:
in... client/ui/MoviePlayer.cs:
...and that's it! Click while the AVI is playing to jump to the mainmenu, or wait until it's ended, without loose windows focus!
And remember: always delete the .dso from your folders, people... i really suffered because of that.
Hope that helps someone...
10/05/2005 (1:31 pm)
I SOLVED IT!!!!!After much struggle of a non-programmer, i mean... :S
Well, thing is, that ::click() instructions is defined only inside the GuiFadeinBitmapCtrl. The avi control accepts other, however... ::onMovieStopped() !!! This instruction, unfortunatelly, will run endlessly so i have to implement some variable filters in the instructions.
In other words, to play a .AVI intro in your game, you have to remake the script like that:
in... client/ui/Startup.Gui :
new GuiFadeinBitmapCtrl(StartupGui) {
profile = "GuiInputCtrlProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "0 0";
extent = "640 480";
minExtent = "8 8";
visible = "1";
helpTag = "0";
bitmap = "./GarageGames";
wrap = "0";
fadeinTime = "3";
waitTime = "10";
fadeoutTime = "3";
};
$endintro=1;
function loadStartup()
{ $endintro=1;
echo ("** Intro Video ***");
exec("starter.fps/client/ui/movieplayer.cs");
schedule(100, 0, END_INTRO); //to check if user ended intro by clicking somewhere
schedule(64000,0, INTRO_END); //to end intro after the times avi finishes (change value to increase time)
}
function INTRO_END()
{
if($endintro !=3)
{
$endintro = 2;
echo ("AVI ENDED NORMALLY");
END_INTRO();
}
}
function END_INTRO()
{
if($endintro == 2)
{
cursorOn();
loadMainMenu();
checkIntroDone();
$endintro = 3;
echo($endintro @"= final value of %endintro, END_INTRO() executed");
}
else
{
if($endintro == 1)
{
schedule(100, 0, END_INTRO);
}
}
}
function IntroGui::onMovieStopped()
{
echo($endintro @"= final value of endintro in IntroGui::onMovieStopped() executed");
if($endintro == 1)
{
$endintro = 2;
}
}just to be sure, here goes the new MoviePlayer.cs:
in... client/ui/MoviePlayer.cs:
new GuiControlProfile (IntroProfile)
{
opaque = false;
fillColor = "0 0 0";
fillColorHL = "0 0 0";
fillColorNA = "0 0 0";
tab = true;
canKeyFocus = false;
};
new GuiAviBitmapCtrl(IntroGui)
{
profile = "IntroProfile";
horizSizing = "width";
vertSizing = "height";
position = "0 0";
extent = "640 480";
minExtent = "8 8";
visible = "1";
variable = "";
helpTag = "0";
useVariable = "1";
aviFileName = "starter.fps/client/ui/INTRO.avi";
setFirstResponder = "1";
letterBox = false;
swapRB = true;
BPlaying = true;
};
Canvas.pushDialog(IntroGui);
IntroGui.play();
function checkIntroDone()
{
echo ("checkIntroDone() executed")
Canvas.popDialog(IntroGui);
IntroGui.delete();
IntroProfile.delete();
}...and that's it! Click while the AVI is playing to jump to the mainmenu, or wait until it's ended, without loose windows focus!
And remember: always delete the .dso from your folders, people... i really suffered because of that.
Hope that helps someone...
#3
10/05/2005 (2:38 pm)
Good job.
#4
10/05/2005 (4:59 pm)
Eric, I really appreciate your taking the time to share your struggle and your solution. I learn a lot from these sorts of threads. Good job. =)
#5
09/04/2006 (10:24 pm)
Is this referring to version 1.3 or 1.4? The reason why I ask is because the version I have, 1.4, does not recognize the play(); function for the line IntroGui.play(); I can't seem to get this working?? The console indicates "Unkown command play". I have tried the guiAviBitmapCtrl.cc and .h file patches and that doesn't seem to do anything either. Anyone have any suggestions??...........Thanx.
#6
Same problem here
08/01/2007 (10:19 am)
Quote:
Is this referring to version 1.3 or 1.4? The reason why I ask is because the version I have, 1.4, does not recognize the play(); function for the line IntroGui.play(); I can't seem to get this working?? The console indicates "Unkown command play". I have tried the guiAviBitmapCtrl.cc and .h file patches and that doesn't seem to do anything either. Anyone have any suggestions??...........Thanx.
Same problem here
Alessandro Loureiro
First, function StartupGui::click() is not recognized. I don't know from where it came from, but this ::click() statement doesn't exist even on the engine HEAD, and that's all the trouble, since the functions needs to be able to detect keystrokes or mouse clicks interruptions. Without this, the intro will either play whole (EVERY TIME!!!!) or jump into the DOS window. I even tryied to load the mainmenu first, but the clicked avi intro stops playing without give the focus to mainmenu. In other words, it doesn't work! I messed with the C++ source to no avail...
Anyone knows how to activate this ::click() condition? It would be the only solution...
thanks again.