This class allows you to interact with AVI movies without using the Microsoft Multimedia Control. This class also allows you to play movies on your form. With the Microsoft Multimedia Control you can only play movies in a separate window. It does not support Windows 64-bit VBA.
Procedure Name | Type | Description |
(Declarations) | Declarations | Declarations and private variables for the CAVI32 class. |
FileName | Property | Get the file name of the AVI file to play. |
Height | Property | Get the height of the playback window. |
hWnd | Property | Get handle of the AVI window. |
hWndParent | Property | Get the handle of the parent window. This property is only valid after calling the OpenAVI method. |
Left | Property | Get the left position of the playback window in pixels, relative to the parent window. |
Length | Property | Get the length of the AVI movie. |
Position | Property | Get the current playback position. |
Stretch | Property | Get the value of the stretch flag. |
Top | Property | Set the top position of the playback window in pixels, relative to the parent window. |
Width | Property | Get the width of the playback window. |
Class_Terminate | Terminate | Close the AVI file. |
CloseAVI | Method | Close the AVI file. |
OpenAVI | Method | Open the AVI file. This must be called before attempting to play the AVI file. |
Pause | Method | Pause the playback. |
Play | Method | Play the AVI file. |
Rewind | Method | Rewind the movie. |
StopPlay | Method | Stop the AVI player. |
PositionMovieWindow | Private | Position the movie playback window. If stretch is True, then make the playback window the size indicated in the width and height properties. Otherwise modify it to the size of the movie starting at the left and top properties. All measurements are in pixels. |
' Example of the CAVI32 Class ' ' To try this example, do the following: ' 1. Create a new form ' 2. Add a command button called 'cmdPlay' ' 3. Add a command button called 'cmdStop' ' 4. Add a command button called 'cmdPause' ' 5. Add a command button called 'cmdRewind' ' 6. Add a check box called 'chkStretch' ' 7. Add an image control called 'ImgMovie' ' 8. Paste all the code from this example to the new form's module ' 9. Run the form ' This example assumes that the sample files are located in the folder named by the following constant. Private Const mcstrSamplePath As String = "C:\TVSBSamp" Private mclsAVI As CAVI32 Private Sub chkStretch_Click() mclsAVI.Stretch = (chkStretch = 1) End Sub Private Sub cmdPause_Click() mclsAVI.Pause End Sub Private Sub cmdPlay_Click() mclsAVI.Play End Sub Private Sub cmdRewind_Click() mclsAVI.Rewind End Sub Private Sub cmdStop_Click() mclsAVI.StopPlay End Sub Private Sub Form_Load() Set mclsAVI = New CAVI32 cmdPlay.Caption = "Play" cmdStop.Caption = "Stop" cmdPause.Caption = "Pause" cmdRewind.Caption = "Rewind" ' Position movie mclsAVI.Left = ImgMovie.Left / Screen.TwipsPerPixelX mclsAVI.Top = ImgMovie.Top / Screen.TwipsPerPixelX mclsAVI.Width = ImgMovie.Width / Screen.TwipsPerPixelX mclsAVI.Height = ImgMovie.Height / Screen.TwipsPerPixelX ' Specify file mclsAVI.FileName = mcstrSamplePath & "\test.avi" ' Set the parent of the movie window mclsAVI.hWndParent = Me.hWnd ' Open movie mclsAVI.OpenAVI End Sub Private Sub Form_Unload(Cancel As Integer) Set mclsAVI = Nothing End Sub
The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.
Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!
Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!
"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."
Van T. Dinh, Microsoft MVP