Playing videos in fullscreen
BlitzMax Forums/BlitzMax Programming/Playing videos in fullscreen
| ||
I am writing a game in BlitzMax and want to show a video between each level to introduce it. I was thinking of buying the MaxGUI add on and using the HTML view to show the movie as FLV video or Quicktime embedded in HTML. The thing is, can you do that in fullscreen, doublebuffered mode? If not, how can you play a cutscene video just like you would find in any commercial game? |
| ||
maxgui -> no fullscreen at all. You need to use a video module to do this. And as you need to be able to do it commercial, it won't be any of those wrapper so far unless theora (libtheora) was wrapped as well. |
| ||
Don't some video players that work in web browsers have their own full-screen mode? |
| ||
How about mplayer? http://www.mplayerhq.hu/ I know it can be embedded fullscreen, but I do not know about the legal aspects of it, but I believe its open source, so it might be something that could be used. |
| ||
What about this Theora module? - http://www.pantson.com/mods/Theora/index.php |
| ||
OK. I found some code buried in this forum that lets me play MPEG-1 videos fullscreen perfect. The only problem is that it opens it's own window to play the video and minimizes the game window. Is there a command to identify the game window and maximize it again? |
| ||
i do recommend using the theora module. Theora movies and module are copyright free. Most MPEG formats are not free formats and most players are based upon a GPL license which means that your code must be freely avaliable. The theora format is free from all restrictions. Unfortunately I cannot get sound working in the module, but there is a method for playign sound in the examples in the archive. To convert your movies to theora using the link in the Theora/index.php page. |
| ||
Hey PantsOn. I downloaded your Theora module, converted a video(using "ff2mpeg") to test using the video converter and rant he sample program pointing to that video but I always get an error: Can't find interface for module "pantson.theora" Wow. I still can't get over how difficult it is to simply play a video file within a BlitzMax application in fullscreen. Why is this so hard to do? Even the old 2D version of Blitz had simple video playback commands. |
| ||
Did you download to a pantson.mod/theora.mod directory in your blitzmax mod directory? You might also need to build modules. <edit> P.S. You are right that are some glaring omissions from BlitzMax which were present in B2D/B3D. It's usually blamed on x-platform support. |
| ||
Blitz uses DirectMedia. Its simple and just there. explain that to the Linux world with no standard and apple with QuickTime ... |
| ||
I finally figured it out! Here is the code I cobbled together to work around the problems I was having. It is not perfect, but it works adequately until the next version of BlitzMax hopefully includes such functionality. Here is the code: ' THIS CODE WILL CREATE A BLITZMAX ANIMATED APPLICATION WHICH LAUNCHES A FULLSCALE .AVI VIDEO ' FILE WHEN THE USER CLICKS ON THE START BUTTON. WHEN THE AVI IS FINISHED PLAYING IT RETURNS TO ' THE STANDARD BLITZMAX ANIMATION. ' THIS CODE WILL WORK WITH THE STANDARD .AVI CODECS LIKE CINEPAK AND INDEO. ' THESE ARE THE COMMANDS WINDOWS NEEDS TO MANIPULATE WINDOWS Global hwnd:Int Extern "Win32" Function mciSendString:Int(pstrCommand$z, lpstrReturnStr$z, wReturnLen:Int, CallBack:Int) = "mciSendStringA@16" Function FindWindow( lpClassName$z, lpWindowName$z ) = "FindWindowA@8" Function FindWindowEx( hwnd1:Int, hwnd2:Int, lpsz1$z, lpsz2$z ) = "FindWindowExA@16" Function SetWindowLong:Int(HWND:Int,nIndex:Int,dwNewLong:Int) = "SetWindowLongA@12" Function GetWindowLong:Int(HWND:Int,nIndex:Int) = "GetWindowLongA@8" Function ShowWindow:Int(HWND:Int,nCmdShow:Int) Function BringWindowToTop:Int(HWND:Int) Function GetActiveWindow:Int() End Extern ' SET UP A STANDARD BLITZMAX PROGRAM Graphics 1024,768,32 SetMaskColor 0, 0, 0 HideMouse() ' LOAD GRAPHICS FOR OUR SIMPLE GUI Global start_btn = LoadImage("gfx/UI/Start_btn.png") Global cursor = LoadImage("gfx/UI/CURSOR.BMP") '---------------------------------------------------------------------------- THE MAIN PROGRAM LOOP While Not KeyDown(KEY_ESCAPE) Cls DrawImage start_btn ,400,500 DrawImage cursor,MouseX(),MouseY() ' --------------------------------------------------------- IF THE USER CLICKS THE START BUTTON, PLAY THE VIDEO FILE THEN '--------------------------------------------------------- RESTORE THE BLITZMAX WINDOW TO NORMAL. If MouseDown(1) If ImagesCollide (cursor, MouseX(), MouseY(), 0, start_btn, 400, 500, 0) ' SWITCH OUR GRAPHICS MODE TO SUIT THE SIZE OF OUR VIDEO FILE Graphics 400,320,32 PlayAVI("test.avi") ' SET THE HWND VARIABLE OUR CURRENT APPLICATION hwnd=GetActiveWindow() ' SET GRAPHICS BACK TO NORMAL Graphics 1024,768,32 ' BRING OUR BLITZMAX APPLICATION WINDOW BACK TO FULLSCREEN ShowWindow(hwnd,SW_MAXIMIZE) BringWindowToTop(hwnd) End If End If Flip Wend ' ----------------------------------------------------------- AVI PLAYBACK FUNCTION Function PlayAVI:Int(FileName:String) Local cmdStr:String = "" Local ReturnCode:Int ReturnCode = mciSendString("close AVI_Device","",0,0) ReturnCode = mciSendString("open " + Chr(34) + filename + Chr(34) + " type avivideo alias AVI_Device","",0,0) If returncode<>0 Then Print "Error opening AVI device. Error code:" + returncode Return False EndIf CmdStr = "play AVI_Device fullscreen wait" returncode = mciSendString(cmdstr ,cmdstr , 0, 0) If returncode<>0 Then Print "Error playing AVI file. Error code:" + returncode Return False Else Return True EndIf End Function |
| ||
the file scructure for the mod should be.. mods/pantson.mod/theora.mod/files (this should structure shuld already be in the archive) You will then need to compile the module. CTRL-D This will require MINGW installed.. Personally I wouls steer away from AVIs as well due to the number of codecs needed nowadays. |