How to Play AVI File in your application
Posted on January 5, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 'MultiMedia - How to Play AVI File in your application Option Explicit 'Add a module to your project and Insert the 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 'Add 2 CommandButtons to your form 'The first one is to open the AVI file and the second one is to close the movie 'Even after the AVI Finish playing, it is still uses memory. So, you need to remove it 'from the memory by pressing the second button. 'Insert the following code to your form: Dim sReturnString As String Private Sub Command1_Click() Dim sFileName As String sReturnString = Space(127) 'Replace C:\WINDOWS\clock.avi with the AVI file you want to play sFileName = "C:\WINDOWS\clock.avi" Call mciSendString("open " & Chr$(34) & sFileName & Chr$(34) & " type avivideo alias video", sReturnString, 127, 0) Call mciSendString("set video time format ms", sReturnString, 127, 0) Call mciSendString("play video from 0", sReturnString, 127, 0) End Sub Private Sub Command2_Click() Call mciSendString("close video", sReturnString, 127, 0) End Sub |