'=============
'QB64VIDEO.BAS
'=============
'Plays a video file in QB64 via MCI commands (WINDOWS ONLY)
'Coded by Dav, forgot what year...
'NOTE: This demo plays a sample video name davpiano.wmv.
' mciSendStringA function plays media files and returns the following:
' 0 = command sucessful
' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
' lpstrCommand is the MCI command string (and optional flags) to send.
' lpstrReturnString is a string that holds any return information.
' uReturnLength is the length of the lpstrReturnString string passed.
' NOTE: If lpstrCommand given doesn't retun a value then lpstrReturnString
' can be empty and uReturnLength can be set to 0.
' hwndCallback contains a callback window handle (only if the Notify flag used in lpstrCommand)
'====================================================================
' mciGetErrorStringA returns error info if the mciSendStringA failed.
' dwError is the return value from the mciSendString function.
' lpstrBuffer string holds the error information returned by the function.
' uLength is the length of the lpstrBuffer string buffer.
'====================================================================
filename$ = "davpiano.wmv" '<========== My video file to play
PRINT filename$
+ " " + "not found."
handle&
= _NEWIMAGE(320, 240, 32) '<===== The x/y size of my video
title$ = "QB64 Video Player - " + filename$
hwnd&
= FindWindow
(0, title$
+ CHR$(0))
a%
= mciSendStringA%
("open " + filename$
+ " style popup", ReturnString$
, LEN(ReturnString$
), 0)
x%
= mciGetErrorStringA%
(a%
, ErrorString$
, LEN(ErrorString$
)) a2%
= mciSendStringA%
("window " + filename$
+ " handle " + STR$(hwnd&
), ReturnString$
, LEN(ReturnString$
), 0) b% = mciSendStringA%("play " + filename$, "", 0, 0)
'=== Play video...
'you can add pause/resume routine here if you want...
x% = mciSendStringA%("stop " + filename$, "", 0, 0)
x% = mciSendStringA%("close " + filename$, "", 0, 0)