Results 1 to 4 of 4

Thread: Play Video In a Control

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member .NetNinja's Avatar
    Join Date
    Oct 2008
    Location
    USA
    Posts
    281

    Thumbs up 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."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width