guiAviBitmapCtrl Windows ONLY fix
by Richard O · in Torque Game Engine · 07/03/2002 (6:43 pm) · 78 replies
A little disclaimer before I get into the code. This is a quick and dirty fix to the guiAviBitmapCtrl module to get it to play AVI's under Windows only (i.e. it will not compile/work on Linux or Mac). All of the below code changes are based upon the current HEAD version:
exec("fps/AVI/avitest.cs");
As far as a Linux and Mac solution, it is on my to do list (no estimate of availability at this time). The above coding changes where done to validate that the existing Windows code was functional.
Rich
[b]In engine\gui\guiAviBitmapCtrl.h[/b] Change the below line (11) from: #if !ENABLE_AVI_GUI || !ENABLE_MPG_GUI to #if !ENABLE_AVI_GUI && !ENABLE_MPG_GUI
[b]In engine\gui\guiAviBitmapCtrl.cc[/b]
Change the below line (23) from:
#define ENABLE_AVI_GUI 0
to
#define ENABLE_AVI_GUI 1
Change the below line (46) from:
#if !ENABLE_AVI_GUI || !ENABLE_MPG_GUI
to
#if !ENABLE_AVI_GUI && !ENABLE_MPG_GUI
Replace the entire function GuiAviBitmapCtrl::sndOpen() (lines 101-117) with the below code:
bool GuiAviBitmapCtrl::sndOpen()
{
char fileBuffer[1024];
Audio::Description desc;
// Build the audio description
desc.mVolume = 1.0f;
desc.mIsLooping = false;
desc.mIs3D = false;
desc.mType = 0;
// Create the audio source
dSprintf(fileBuffer, sizeof(fileBuffer), "%s", mWavFilename);
mWavHandle = alxCreateSource(&desc, fileBuffer, 0);
return (mWavHandle != NULL_AUDIOHANDLE);
}In order to test the above changes I created a directory under fps called AVI. I then created the below script (avitest.cs) in that directory. Here is the source code to the script:// Issue the below command at the console:
//
// exec("fps/AVI/avitest.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 = "fps/AVI/test.avi";
wavFileName = "fps/AVI/test.wav";
setFirstResponder = "1";
letterBox = true;
// letterBox = false;
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);
}You will need to create a test AVI (test.avi) and WAV (test.wav) file and place them in the fps/AVI directory prior to executing the above script. To test the AVI control, open the console from the main menu and issue the command:exec("fps/AVI/avitest.cs");
As far as a Linux and Mac solution, it is on my to do list (no estimate of availability at this time). The above coding changes where done to validate that the existing Windows code was functional.
Rich
#2
07/03/2002 (7:02 pm)
VERY NICE Richard! Works very well (as you say, for Windows). And many thanks to John Q and others who were/are working to get this fully implemented on all ports. Hopefully GG will fix this at least for the windows version.
#3
Yes all of the necessary Windows files are being included. The key Windows file is:
#include
which is part of the Windows SDK.
As far as the other platforms, going through Platform:: would be the preferred way to go (in my opinion). Whether we design some form of generic cross-platform AVI file or have to code each platform separately is still up in the air. I need to take sometime to go through the excellent work that John Q. did with MPEG/SDL for the Linux part. This should help make the coding decision easier.
@Desmond,
Thank you for the compliments. I should have taken more time to wrap the Windows code (e.g. #define's), instead of the bruit force approach as I did. Well, at least the Windows version works. :)
07/03/2002 (7:27 pm)
@Robert,Yes all of the necessary Windows files are being included. The key Windows file is:
#include
which is part of the Windows SDK.
As far as the other platforms, going through Platform:: would be the preferred way to go (in my opinion). Whether we design some form of generic cross-platform AVI file or have to code each platform separately is still up in the air. I need to take sometime to go through the excellent work that John Q. did with MPEG/SDL for the Linux part. This should help make the coding decision easier.
@Desmond,
Thank you for the compliments. I should have taken more time to wrap the Windows code (e.g. #define's), instead of the bruit force approach as I did. Well, at least the Windows version works. :)
#4
in the project to work? I followed the above, but my test avi does not play. The script execs fine from the console though.
I found where vfw.h gets included by the define, strange this will not work for me.
07/03/2002 (9:20 pm)
Does this line need to be added #include in the project to work? I followed the above, but my test avi does not play. The script execs fine from the console though.
I found where vfw.h gets included by the define, strange this will not work for me.
#5
thanks you soooooo much!! That's absolutely great - works like a charm... if you get it to run on the other platforms as well, you're my hero!! ;-) Ah, heck, you already are!! :-) Thanks again!
EDIT: but somehow the sound won't play for me... any idea? I don't get an error, it just doesn't play...
EDIT: nevermind, was a file problem.... :-)
07/03/2002 (9:30 pm)
Richard-thanks you soooooo much!! That's absolutely great - works like a charm... if you get it to run on the other platforms as well, you're my hero!! ;-) Ah, heck, you already are!! :-) Thanks again!
EDIT: but somehow the sound won't play for me... any idea? I don't get an error, it just doesn't play...
EDIT: nevermind, was a file problem.... :-)
#6
Since you are a developer, I will skip the questions 'Did you make sure the AVI file exists, Is it in the correct directory', etc. For a quick test try loading the T2IntroC15.avi file from Tribes 2. It should play without any problems.
You also want to check your AVI file settings. I have only been able to load AVI's that have:
If you want to play the accompanying WAV file (T2Intro.wav) that gets played along with the T2IntroC15.avi file, you will need to convert it. The T2Intro.wav has an Audio format of IMA ADPCM which will not play. You will need to convert it to:
@Stefan,
You are welcome. I should have put in error checking into the test script to avoid the situation that you saw (I have gotten burned by that also). If you run into problems playing other AVI's or WAV's, stick a break point on line # 842 which should be the first line of the function GuiAviBitmapCtrl::onWake(). Most problems can be found in this part of the code.
Rich
07/04/2002 (4:09 am)
@Shawn,Since you are a developer, I will skip the questions 'Did you make sure the AVI file exists, Is it in the correct directory', etc. For a quick test try loading the T2IntroC15.avi file from Tribes 2. It should play without any problems.
You also want to check your AVI file settings. I have only been able to load AVI's that have:
Video Sample Size 24 bit Video Compression Cinepak CodecSince there are several places in the code that return an error, but the error is not passed back to the test script, I would recommend that you put a break point on line #582 which should read:
mHic = ICLocate(ICTYPE_VIDEO, fccHandler, pbiSrc, 0, ICMODE_DECOMPRESS);If you still can not get your AVI file to play, feel free to email it to me and I will look at it (I can handle an email of up to 100 Meg).
If you want to play the accompanying WAV file (T2Intro.wav) that gets played along with the T2IntroC15.avi file, you will need to convert it. The T2Intro.wav has an Audio format of IMA ADPCM which will not play. You will need to convert it to:
Audio format PCM Average data rate 176.400 Kb/second Sample rate 44.100 kHz Audio sample size 16 bit Channels 2 (Stereo)
@Stefan,
You are welcome. I should have put in error checking into the test script to avoid the situation that you saw (I have gotten burned by that also). If you run into problems playing other AVI's or WAV's, stick a break point on line # 842 which should be the first line of the function GuiAviBitmapCtrl::onWake(). Most problems can be found in this part of the code.
Rich
#7
07/04/2002 (3:12 pm)
Thanks Rich, it appeared to be the codec I was using. cudos for providing this.
#8
10/17/2002 (6:49 am)
how would i get this to run automaticly the firstime you run torque? and/or beable to exec an .avi from a button in the mainmenu.gui .
#9
To get an AVI file to play the first time only, you are going to need to create a new $pref setting that can be set to 1 or 0 depending upon whether or not the AVI file has played. You probably want the AVI to play prior to the MainMenu being displayed, so look at the script example\fps\client\init.cs around line #99 where it makes the call to the function loadMainMenu(). You will need to invoke your function that displays the AVI file prior to this call. Here is an example:
Rich
10/17/2002 (7:35 am)
Ace,To get an AVI file to play the first time only, you are going to need to create a new $pref setting that can be set to 1 or 0 depending upon whether or not the AVI file has played. You probably want the AVI to play prior to the MainMenu being displayed, so look at the script example\fps\client\init.cs around line #99 where it makes the call to the function loadMainMenu(). You will need to invoke your function that displays the AVI file prior to this call. Here is an example:
if (!$pref::AVI::SkipIntro)
{
// Throw up the AVI intro
displayAVIIntro();
}As far as invoking an AVI from a pushbutton, there are several different ways to do this. The easiest way would be to modify the command parameter in the GuiButtonCtrl() object definition to call your function to display the AVI.Rich
#10
i guess what i dont know is what the command is that actualy starts the avi playing i guess i must be missing somthing could could anyone fill me in a lil more?
I am useing this code (un changed)
thanks
10/21/2002 (6:51 am)
i still been tring (for days when i have the time of course)i guess what i dont know is what the command is that actualy starts the avi playing i guess i must be missing somthing could could anyone fill me in a lil more?
I am useing this code (un changed)
thanks
#11
10/21/2002 (8:04 am)
If you had bothered in reading the code you wouldn't be making this kind of questions.
#12
www.planetquake.com/noescape/torque/avistartup.htm
thanks
10/23/2002 (9:37 pm)
Well not everyone is at the same level of knowledge. Heres how i got the avi to automaticly start when you click the .exe. www.planetquake.com/noescape/torque/avistartup.htm
thanks
#13
02/24/2003 (3:36 pm)
Well this all works perfectly. I just wish to inform you all that if you add the Oggvorbis support you can play .ogg files instead of .wav. So I'm guessing that if someone (with more programing skills than me) would add xvid (since it's free) to the code it should work perfectly.
#15
I personally have not required Linux support for the projects that I am working on. John Q. has added support for SMPEG, but I have never tested it (at the time I was working on a Windows/Mac solution). I did spend sometime attempting to get OpenDivX integrated, but I ran into problems with the sample programs supplied (i.e. not evening compiling, GPF's,...etc.), so I gave up. Unless I am missing something, it looks like development of OpenDivX has stopped and I just don't have the time to go and fix it.
Rich
04/04/2003 (5:46 am)
Alastair,I personally have not required Linux support for the projects that I am working on. John Q. has added support for SMPEG, but I have never tested it (at the time I was working on a Windows/Mac solution). I did spend sometime attempting to get OpenDivX integrated, but I ran into problems with the sample programs supplied (i.e. not evening compiling, GPF's,...etc.), so I gave up. Unless I am missing something, it looks like development of OpenDivX has stopped and I just don't have the time to go and fix it.
Rich
#16
04/04/2003 (8:15 am)
Hmm, I did not add support for SMPEG. Maybe someone else did?
#17
The original version of guiAviBitmapCtrl.cc had SMPEG support it in and I thought you where the developer who did the Linux port. Please accept my apology.
Rich
04/04/2003 (10:35 am)
John,The original version of guiAviBitmapCtrl.cc had SMPEG support it in and I thought you where the developer who did the Linux port. Please accept my apology.
Rich
#18
04/04/2003 (11:11 am)
Heheh...no problem. Its a bit confusing. Yes I did a lot of the client port, but I did not do the SDL/SMPEG stuff in guiAviBitmapCtrl.cc. That is a remnant of Loki's port. Most of other Loki work was rewritten for legal reasons.
#19
According to Richard's instructions I've created sample gui for playing intro movie (with 'aviFileName' set to 'T2IntroC15.avi' from T2 and 'wavFileName' to one of standard Windows jingle).
When I call play() I can hear the music but there is no video (only white, empty rectangle in place it should be). I've checked the avi file has been opened correctly and video codec found as well but nothing appeared on my screen :-(
BTW: Is there possibility to play sound directly stream from movie or need I always to use it as separate file?
Any ideas?
Roman
06/30/2003 (6:37 am)
I found another problem with 'guiAviBitmapCtrl':According to Richard's instructions I've created sample gui for playing intro movie (with 'aviFileName' set to 'T2IntroC15.avi' from T2 and 'wavFileName' to one of standard Windows jingle).
When I call play() I can hear the music but there is no video (only white, empty rectangle in place it should be). I've checked the avi file has been opened correctly and video codec found as well but nothing appeared on my screen :-(
BTW: Is there possibility to play sound directly stream from movie or need I always to use it as separate file?
Any ideas?
Roman
#20
Could you please post the script code that you are using and I will see if I can spot anything that might be causing the problem you are having.
Thank you.
Rich
07/02/2003 (6:21 am)
Roman,Could you please post the script code that you are using and I will see if I can spot anything that might be causing the problem you are having.
Thank you.
Rich
Torque 3D Owner Robert Blanchet Jr.
I have but just a small little question. All the necessary header files were already there for windows?
And what are your plans for getting this to work in Linux and the MacOS? Are you going to go through Platform:: some how are do you think there is an easier solution?