Have you ever wanted to play videos in a control on a form without using Windows Media Player? Here's how:
USAGE:Code:Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer Const WS_CHILD As Integer = &H40000000 Private Sub PlayMedia(ByRef FileName As String, ByVal Window As Control) FileName = Chr(34) & FileName & Chr(34) mciSendString("Open " & FileName & " alias MediaFile parent " & CStr(Window.Handle.ToInt32) & " style " & CStr(WS_CHILD), Nothing, 0, 0) mciSendString("put MediaFile window at 0 0 " & CStr(PixelToTwip(Window.ClientRectangle.Width) / 15) & " " & CStr(PixelToTwip(Window.ClientRectangle.Height) / 15), Nothing, 0, 0) mciSendString("Play MediaFile", Nothing, 0, 0) End Sub Private Function PixelToTwip(ByVal Pixel As Integer) As Double Return Pixel * 15 End Function
Code:PlayMedia("FileName", PictureBox1)




Reply With Quote