PDA

Click to See Complete Forum and Search --> : Playing Video Files...


Dec 5th, 2000, 04:02 PM
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.

Wak
Dec 6th, 2000, 08:26 PM
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.