Hi guys,
I have a rather straightforward question: what am I doing wrong
?
The following code does nothing more than attempt to play a video file whose path you enter into the box on the top in a label control.
With DivX/XviD files (regardless of source), it plays the video at several times the normal speed, minus sound.
For MPG files, only the sound is played with no video.
Any ideas where I am going wrong?
Thanks,
Oliver
------------------
I have a rather straightforward question: what am I doing wrong

The following code does nothing more than attempt to play a video file whose path you enter into the box on the top in a label control.
With DivX/XviD files (regardless of source), it plays the video at several times the normal speed, minus sound.
For MPG files, only the sound is played with no video.
Any ideas where I am going wrong?
Thanks,
Oliver
Code:
#PBFORMS CREATED V1.50 '------------------------------------------------------------------------------ ' The first line in this file is a PB/Forms metastatement. ' It should ALWAYS be the first line of the file. Other ' PB/Forms metastatements are placed at the beginning and ' end of "Named Blocks" of code that should be edited ' with PBForms only. Do not manually edit or delete these ' metastatements or PB/Forms will not be able to reread ' the file correctly. See the PB/Forms documentation for ' more information. ' Named blocks begin like this: #PBFORMS BEGIN ... ' Named blocks end like this: #PBFORMS END ... ' Other PB/Forms metastatements such as: ' #PBFORMS DECLARATIONS ' are used by PB/Forms to insert additional code. ' Feel free to make changes anywhere else in the file. '------------------------------------------------------------------------------ #COMPILE EXE #DIM ALL '------------------------------------------------------------------------------ ' ** Includes ** '------------------------------------------------------------------------------ #PBFORMS BEGIN INCLUDES #IF NOT %DEF(%WINAPI) #INCLUDE "WIN32API.INC" #ENDIF #PBFORMS END INCLUDES '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Constants ** '------------------------------------------------------------------------------ #PBFORMS BEGIN CONSTANTS %IDD_MAINFRAME = 101 %IDC_PATH = 1001 %IDC_VIDEO = 1002 %IDC_PLAY = 1003 %IDC_STOP = 1004 #PBFORMS END CONSTANTS '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Declarations ** '------------------------------------------------------------------------------ DECLARE CALLBACK FUNCTION ShowMAINFRAMEProc() DECLARE FUNCTION ShowMAINFRAME(BYVAL hParent AS DWORD) AS LONG #PBFORMS DECLARATIONS '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Main Application Entry Point ** '------------------------------------------------------------------------------ FUNCTION PBMAIN() ShowMAINFRAME %HWND_DESKTOP END FUNCTION '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** CallBacks ** '------------------------------------------------------------------------------ CALLBACK FUNCTION ShowMAINFRAMEProc() LOCAL x$,vhndl&,serr& SELECT CASE AS LONG CBMSG CASE %WM_INITDIALOG ' Initialization handler CASE %WM_NCACTIVATE STATIC hWndSaveFocus AS DWORD IF ISFALSE CBWPARAM THEN ' Save control focus hWndSaveFocus = GetFocus() ELSEIF hWndSaveFocus THEN ' Restore control focus SetFocus(hWndSaveFocus) hWndSaveFocus = 0 END IF CASE %WM_COMMAND ' Process control notifications SELECT CASE AS LONG CBCTL CASE %IDC_STOP IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN CONTROL GET TEXT CBHNDL,%IDC_PATH TO x$ CALL mciSendString("close " + $DQ+x$+$DQ, "", %NULL, %NULL) END IF CASE %IDC_PLAY IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN CONTROL GET TEXT CBHNDL,%IDC_PATH TO x$ CONTROL HANDLE CBHNDL,%IDC_VIDEO TO vhndl& serr&=mciSendString("open " + $DQ+x$+$DQ, "", %NULL, %NULL) IF serr THEN MSGBOX "Error opening." EXIT FUNCTION END IF serr&=mciSendString("window " + $DQ + x$ + $DQ + " handle " + FORMAT$(vhndl&), BYVAL %NULL, 0, 0) IF serr THEN MSGBOX "Error setting window." EXIT FUNCTION END IF serr&=mciSendString("play " + $DQ+x$+$DQ, "", %NULL, %NULL) IF serr THEN MSGBOX "Error playing." EXIT FUNCTION END IF END IF END SELECT END SELECT END FUNCTION '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Dialogs ** '------------------------------------------------------------------------------ FUNCTION ShowMAINFRAME(BYVAL hParent AS DWORD) AS LONG LOCAL lRslt AS LONG #PBFORMS BEGIN DIALOG %IDD_MAINFRAME->-> LOCAL hDlg AS DWORD DIALOG NEW hParent, "Video Player", 70, 70, 408, 324, %WS_POPUP OR _ %WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR _ %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _ %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_WINDOWEDGE OR _ %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _ %WS_EX_RIGHTSCROLLBAR, TO hDlg CONTROL ADD TEXTBOX, hDlg, %IDC_PATH, "", 0, 15, 315, 12 CONTROL ADD LABEL, hDlg, %IDC_VIDEO, "", 20, 35, 355, 260 CONTROL ADD BUTTON, hDlg, %IDC_PLAY, "&Play", 319, 15, 41, 15 CONTROL ADD BUTTON, hDlg, %IDC_STOP, "&Stop", 366, 15, 41, 15 #PBFORMS END DIALOG DIALOG SHOW MODAL hDlg, CALL ShowMAINFRAMEProc TO lRslt #PBFORMS BEGIN CLEANUP %IDD_MAINFRAME #PBFORMS END CLEANUP FUNCTION = lRslt END FUNCTION '------------------------------------------------------------------------------
Comment