Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Jerry Y
  Where is Jerry Y?
 Toronto
 Canada
 Jerry Y
 To: Pete Sass
  Where is Pete Sass?
 Marathon, Ontario
 Canada
 Pete Sass
 Tags
Subject: RE: How to play video in VFP
Thread ID: 373502 Message ID: 373530 # Views: 77 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: General VFP Topics
Date: Saturday, March 23, 2013 12:04:05 AM         
   


hi Pete,

I created mmp.prg, bringtofront.prg.
I added an OLE Windows Media Player (olecontrol1) on the form.
I inserted in the Activate: do mmp

When running the program, the Open window pop-up looking for video file.
I choose the video file.
after that, nothing happens.

Please advise.

Thanks for the help.

Jerry





> > I want to add play video feature in VFP
> >
> > I added an OLE: VideoLAN VLC ActiveX Plugin v2 on my form.
> >
> > Now I have a pylon picture on my form, but didn't know how to turn it on.
> >
> > Please help
> >
> > Regards,
> >
> > Jerry
>
>
> Hi Jerry,
>
> Why not use the stock Windows media player?
>
>
> I have went with 100% Windows API calls to make this work - lol.
>
> I have a restaurant POS systems were videos are played via the main till and play on several flat panel TV's in
> the resturant.
> In a command button on the main POS form call Play Video's I have the following code:
>
>
* --- MMP.prg
> * --- Custom UDF() call to bring the MMP to the front if it is hidden behind
> * --- other VFP forms.
> LOCAL llIsRunning
> llIsRunning = BringToFront("Windows Media Player")
> IF llIsRunning = .T.
>    RETURN
> ENDIF
>    
> * --- To select and play videos from a selection in a folder location.
> DECLARE INTEGER ShellExecute IN shell32.dll ; 
> 	INTEGER hndWin, STRING cAction, STRING cFileName, ; 
> 	STRING cParams, STRING cDir, INTEGER nShowWin
> 
> * --- Get what to play from the default location for all multi-media files.
> SET DEFAULT TO (p_MMPfolder)
> lcMMPFile = GetFile("wav,mp3,au,wmv,mpg,avi")
> 
> * --- Call and play the Multi-media file.
> ShellExecute(0,"play",lcMMPFile,"","",1)
> 
> * --- Set path back to default setting.
> SET DEFAULT TO (pRoot)

>
>
>
> The above code calls a UDF()function that will bring to the front the Media player. You need this as a
> seperate .prg inside your VFP prject.
>
* --- BringToFront.prg
> * --- Coded as a UDF call.
> * --- Syntax:  = BringToFront("Window Name that should be running")
> * --- In my case: = BringToFront("Windows Media Player")
> * --- Interesting bit of API work - lol
> PARAMETERS lcWinName
> #DEFINE GW_HWNDLAST 1
> #DEFINE GW_HWNDNEXT 2
> #DEFINE GW_CHILD 5
> DO declare
>  
> CREATE CURSOR csResult (hWnd N(12), isvisible N(1),;
>     leftpos I, toppos I, rightpos I, botpos I, wincap C(64), classname C(64))
>  
> LOCAL hDesktop, hFirstChild, hLastChild, rc, cWinCap, cWinClass,;
>     nVisible, nLeft, nTop, nRight, nBottom
>  
> hDesktop = GetDesktopWindow()
> hFirstChild = GetWindow(hDesktop, GW_CHILD)
> hLastChild = GetWindow(hFirstChild, GW_HWNDLAST)
>  
> hCurrent = hFirstChild
> DO WHILE .T.
>     cWinCap = GetWinText(hCurrent)
>     cWinClass= GetClsName(hCurrent)
>     nVisible = IsWindowVisible(hCurrent)
>  
>     rc = Repli(Chr(0),16)
>     = GetWindowRect(hCurrent, @rc)
>     nLeft = buf2dword(SUBSTR(rc, 1,4))
>     nTop = buf2dword(SUBSTR(rc, 5,4))
>     nRight = buf2dword(SUBSTR(rc, 9,4))
>     nBottom = buf2dword(SUBSTR(rc, 13,4))
>  
>     INSERT INTO csResult VALUES (hCurrent, nVisible,;
>         nLeft, nTop, nRight, nBottom, cWinCap, cWinClass)
>  
>     IF hCurrent = hLastChild
>         EXIT
>     ENDIF
>     hCurrent = GetWindow(hCurrent, GW_HWNDNEXT)
> ENDDO
> GO TOP
> 
> * --- Locate if Windows application passed into the UDF() exists and is running.
> LOCATE FOR ALLTRIM(WINCAP) = lcWinName
> IF FOUND()
>    LOCAL lnWinHandleNo, nCmdShow 
>    lnWinHandleNo = Hwnd
> 
>    * --- Win API to bring window to front.
>    DECLARE INTEGER BringWindowToTop IN Win32API ;
>    INTEGER hWnd
>    * --- If Window application is running so activate it and bring to the front.
>    BringWindowToTop(lnWinHandleNo)
> 
>    GO TOP
>    * --- BOTPOS number is required here to obtain the Window handle number
>    * --- specifically if the Window has been minimized.
>    LOCATE FOR ALLTRIM(WINCAP) = lcWinName .AND. BOTPOS = -31973
>    IF FOUND()
>       lnWinHandleNo = Hwnd
>       * --- Second parameter tells what to do this the Window.
>       * --- See this link for all parameters: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx
>       nCmdShow      = 9
> 
>       * --- Win API to restore it in the event it was miniimized.
>       DECLARE INTEGER ShowWindow IN user32; 
>       INTEGER hwnd,; 
>       INTEGER nCmdShow
>    
>       * --- If Window application has been minimized, restore it. 
>       ShowWindow(lnWinHandleNo, nCmdShow)
>    ENDIF
>    
>    RETURN .T.
> 
> ELSE
> 
>    * --- Do nothing as Windows name passed does not exist and is not running.
>    RETURN .F.
> 
> ENDIF
>    
> * --- BROWSE NORMAL NOWAIT  && Un-star for debugging purposes.
> * --- End of main call here.
> 
> * --- Delcare all API calls and required functions below.
> DECLARE INTEGER BringWindowToTop IN Win32API ;
>    INTEGER hWnd
>  
> FUNCTION GetClsName(hWindow)
>     LOCAL nBufsize, cBuffer
>    
>     cBuffer = Repli(Chr(0), 250)
>     nBufsize = GetClassName(hWindow, @cBuffer, Len(cBuffer))
> RETURN SUBSTR(cBuffer, 1, nBufsize)
>  
> FUNCTION GetWinText(hWindow)
>     * --- Returns window title bar text if found.
>     LOCAL cBuffer, nResult
>     cBuffer = Space(250)
>     nResult = GetWindowText(hWindow, @cBuffer, Len(cBuffer))
> RETURN SUBSTR(cBuffer, 1, nResult)
>  
> FUNCTION buf2dword(lcBuffer)
> RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
>     BitLShift(Asc(SUBSTR(lcBuffer, 2,1)),  8) +;
>     BitLShift(Asc(SUBSTR(lcBuffer, 3,1)), 16) +;
>     BitLShift(Asc(SUBSTR(lcBuffer, 4,1)), 24)
>  
> PROCEDURE declare
>     DECLARE INTEGER GetDesktopWindow IN user32
>     DECLARE INTEGER GetWindow IN user32 INTEGER hwnd, INTEGER wFlag
>     DECLARE INTEGER GetWindowRect IN user32 INTEGER hwnd, STRING @lpRect
>     DECLARE INTEGER IsWindowVisible IN user32 INTEGER hWnd
>  
>     DECLARE INTEGER GetWindowText IN user32;
>         INTEGER hwnd, STRING @lpString, INTEGER cch
>  
>     DECLARE INTEGER GetClassName IN user32;
>         INTEGER hWnd, STRING lpClassName, INTEGER nMaxCount

>
>
> Pete "the IceMan", from the Great White North of Canada.
> www.marathongriffincomputers.com
> Home of the Canadian and US download for Chen's VFP C++ Compiler
> http://www.marathongriffincomputers.com/VFP-C++-Compiler.html

ENTIRE THREAD

How to play video in VFP Posted by Jerry Y @ 3/22/2013 5:32:41 PM
RE: How to play video in VFP Posted by Pete Sass @ 3/22/2013 8:17:01 PM
RE: How to play video in VFP Posted by Jerry Y @ 3/23/2013 12:04:05 AM
RE: How to play video in VFP Posted by Michael Goslin @ 3/22/2013 9:10:32 PM
RE: How to play video in VFP Posted by Jerry Y @ 3/22/2013 11:14:29 PM
RE: How to play video in VFP Posted by Naten Baptista @ 11/21/2016 2:26:15 AM
RE: How to play video in VFP Posted by Tore Bleken @ 11/21/2016 7:52:52 AM
RE: How to play video in VFP Posted by Naten Baptista @ 11/21/2016 8:07:06 AM
RE: How to play video in VFP Posted by Tore Bleken @ 11/21/2016 8:22:41 AM
RE: How to play video in VFP Posted by Naten Baptista @ 11/21/2016 2:26:40 AM