Results 1 to 2 of 2

Thread: Playing Video Files...

  1. #1
    Guest

    Question

    I need to play video files at the beginning of my game. I got the example at vb-world.net to work, but it opens up a new window. Someone posted a comment in that example that's supposed to put the video in a picturebox but it doesn't work for some reason. I don't want to use any controls, just all API. I'm using the mciSendString API right now. So what I want to do is open a video file in a picturebox (or other hWnd) and then let the video play.

  2. #2
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    Plays Mpeg's and Avi

    Create a new form with a frame called frmVideo.

    <hr>

    option explicit

    Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

    Private Sub Form_Load()
    Dim SendString As String
    Dim LenShort As Long
    Dim ShortPath As String
    Dim tmp As String * 255
    Dim fileName As String
    Dim hwnd As Long
    Dim typeDevice As String
    Dim retVal As Integer

    If LCase(Right(File, 4)) = ".avi" Then 'Avi-Movie TypeDevice = "AviVideo"
    Else 'else this mean it mpg,mp3,mp2,mp1,wav,,,etc then we will choose "MpegVideo" type
    TypeDevice = "MPEGVideo"
    End If

    hwnd = frmVideo.hWnd

    'fileName = the MPEG that you wish to open
    LenShort = GetShortPathName(fileName, tmp, 255)
    ShortPath = Left$(tmp, LenShort)

    SendString = ("open " & ShortPath & "type " & _ typeDevice & " Alias mpeg parent " & hwnd & _
    " Style 1073741824")

    retVal = mciSendString(SendString, 0&, 0&, 0&)
    'retVal will Return 0 if success, and anything else = error

    'This first section opens the selected MPEG or Avi and
    'the next section will play it.

    SendString = "play mpeg from " & vbNullString & " to " & _ vbNullstring

    RetVal = mciSendString(SendString, 0&, 0&, 0&)

    'Once again will return 0 if success

    End Sub

    <hr>

    Try this, it should work.
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

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