Playing an AVI File

This tip demonstrates how to play an AVI video file without using the Multimedia (MCI) Control.

1. Add a basic module with following code

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

2. Add following code to Form1

Private Sub Form_Activate()
Dim returnstring As String
FileName As String 
returnstring = Space(127) 
'Avifile to play
FileName = "F:\Funstuff\Videos\Highperf\Welcome1.avi" 
erg = mciSendString("open " & Chr$(34) & FileName & _
Chr$(34) & " type avivideo alias video", returnstring, _
127, 0)
erg = mciSendString("set video time format ms", _
returnstring, 127, 0)
erg = mciSendString("play video from 0", returnstring, _
127, 0)
End Sub

'It is important to close the video, even if the file to play has run out. To close the video, use the following line of code:

erg = mciSendString("close video", returnstring, 127, 0)

It's important to close the line, even the file to play has run out.


Insurance College Student | Low Cost Moving Companies | Funny T-Shirts | Asterisk Voip Services | Life Insurance for Smokers