Playing videos in fullscreen

BlitzMax Forums/BlitzMax Programming/Playing videos in fullscreen

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

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