THIS.Enabled= .F.
*!* Check to make sure a media file is not already open
cCmd = ("STATUS FoxMedia READY")
IF THISFORM.doMCI(cCmd) = "true" THEN
*!* If one is, close it
cCMD = ("CLOSE FoxMedia WAIT")
THISFORM.doMCI(cCmd)
*!* And use the custom Disable method of the form to disable
*!* all appropriate controls
THISFORM.disable(.T.)
ENDIF
*!* Prompt the user for the media file to open
cFileName = "VIDEOREC\"+"R"+LTRIM(STR(YRCODI))+".MP4" && era: cFileName = GETFILE("avi|mov|wav|mid","Select file to play")
SET COMPATIBLE ON
TamVideo=FSIZE(cFileName)/1024
SET COMPATIBLE OFF
IF !EMPTY(cFileName) THEN
_SCREEN.MousePointer = 11
THISFORM.lblLoading.visible = .T.
* Returns Handle of Main VFP Window
Main_hWnd =_VFP.hWnd
* Get Handle of the form with FOXTOOLS.FLL
cur_window = THISFORM.HWnd
NullPointer = 0
*!* Set up open MCI command into string variable
cCmd = ('OPEN "' + cFileName + '" alias FoxMedia' + ;
' style child parent ' + ALLTRIM(STR(cur_window)) + ' WAIT')
*!* Execute the MCI command
THISFORM.doMCI(cCmd)
*!* Check to see if MCI command succeeded
IF THISFORM.MCIerror > 0 THEN
*!* If not, it might be a non-visual media
*!* We'll try to open it without setting the window parent
cCmd = ('OPEN "' + cFileName + '" alias FoxMedia WAIT')
THISFORM.doMCI(cCmd)
IF THISFORM.MCIerror > 0 THEN
*!* Nope, still won't open. Some other error.
*!* Let's show the user the MCI error and get out
messagebox(THISFORM.MCIerrorString)
THISFORM.lblLoading.visible = .F.
_SCREEN.MousePointer = 0
RETURN
ELSE
*!* It's not a visual media, so let's show a label
*!* to let the user know the media has been loaded
THISFORM.lblNonVisual.visible = .T.
ENDIF
ELSE
*!* It does have visual media, so we need to set up the window
*!* it will play in.
*!* Get the window handle of the window playing the video
cCmd = "status FoxMedia window handle wait"
hWin = INT(VAL(THISFORM.doMCI(cCmd)))
*!* Once we have the window handle, we need to position
*!* the video window to be the same position and size
*!* as our player rectangle on the form
x1Pos = THISFORM.player.LEFT
y1Pos = THISFORM.player.TOP
x2Pos = THISFORM.player.width
y2pos = THISFORM.player.height
*!* Use the SetWindowPos Windows function to set position and size
setWindowPos(hWin,0,x1Pos,y1Pos,x2Pos,y2Pos,0)
*!* Everything's done, let's show the video
cCmd = ("WINDOW FoxMedia state show")
THISFORM.doMCI(cCmd)
ENDIF
*!* Set the device to use milliseconds when setting/getting position
THISFORM.doMCI("SET FoxMedia time format milliseconds")
*!* Enable all appropriate controls
THISFORM.disable(.F.)
THISFORM.lblLoading.visible = .F.
THISFORM.cmdPause.Enabled = .F.
THISFORM.cmdStop.Enabled = .F.
_SCREEN.MousePointer = 0
ENDIF