Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes) Play Video - Minimal Code
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode = 1
#Include "Win32API.inc"
#Include Once "dshow.inc"
#Include Once "ole2utils.inc" ' For IUnknown_Release
%IDC_Graphic = 500
%WM_GraphNotify = %WM_User+13
Global hDlg As Dword
' Interface pointers
Global pIGraphBuilder As IGraphBuilder
Global pIMediaControl As IMediaControl
Global pIMediaEventEx As IMediaEventEx
Global pIVideoWindow As IVideoWindow
Function PBMain() As Long
Dialog New Pixels, 0, "Direct Show Tests",,,600,400, %WS_OverlappedWindow or %WS_ClipChildren To hDlg
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local w,h As Long, rc As Rect
Select Case Cb.Msg
Case %WM_InitDialog
PlayMovieInWindow(hDlg, "bubbles.mov")
Case %WM_Size
GetClientRect hDlg, rc
If IsObject(pIVideoWindow) Then
pIVideoWindow.SetWindowPosition(rc.Left, rc.Top, rc.Right, rc.Bottom)
RedrawWindow hDlg, rc, 0, %RDW_INVALIDATE Or %RDW_UPDATENOW
End If
End Select
End Function
Sub PlayMovieInWindow (ByVal hwnd As Dword, ByRef wszFileName As WStringZ)
Local hr As Long
pIGraphBuilder = NewCom ClsId $CLSID_FilterGraph ' Create an instance of the IGraphBuilder object
pIMediaControl = pIGraphBuilder ' Get reference pointers
pIMediaEventEx = pIGraphBuilder
pIVideoWindow = pIGraphBuilder
hr = pIGraphBuilder.RenderFile(wszFileName) ' Render the file
pIVideoWindow.Owner = hwnd
pIVideoWindow.WindowStyle = %WS_Child Or %WS_ClipSiblings Or %WS_ClipChildren
pIMediaControl.Run ' Run the graph
End Sub
http://www.garybeene.com/sw/gbsnippets.htm