-
Nov 10th, 2008, 10:55 AM
#1
Thread Starter
Hyperactive Member
Play Video In a Control
Have you ever wanted to play videos in a control on a form without using Windows Media Player? Here's how:
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
USAGE:
Code:
PlayMedia("FileName", PictureBox1)
Last edited by .NetNinja; Nov 10th, 2008 at 02:24 PM.
"Don't try to be a great man. Just be a man and let history make its own judgement."
-
Nov 20th, 2008, 12:38 AM
#2
Lively Member
Re: Play Video In a Control
thank you very much for the submission... works great right off the bat... all i did was add a picturebox and a button... also runs in its own thread... with audio.... but question how would i say pause... and stop.... basically how would i control the video
thank you
-
Nov 20th, 2008, 07:28 AM
#3
Thread Starter
Hyperactive Member
Re: Play Video In a Control
Everything can be found under mciSendString Multimedia Command Strings.
But, for example, to pause the video you would simple do this:
Code:
mciSendString("pause MediaFile", Nothing, 0, 0)
"Don't try to be a great man. Just be a man and let history make its own judgement."
-
Dec 17th, 2009, 04:02 PM
#4
Lively Member
Re: Play Video In a Control
Does anyone know how to play another video after the first one has played? It does seem to do anything if I call the PlayMedia function with a different path.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|