• The computer of the 90’s is the multimedia computer (graphics,
sounds, video). Windows provides a set of rich multimedia functions we can use
in our Visual Basic applications. Of course, to have access to this power, we
use the API. We’ll briefly look at using the API to play video files with
the AVI (audio-visual interlaced) extension.
• In order to play AVI files, your computer needs to have software such
as Video for Windows (from Microsoft) or QuickTime for Windows (from Apple) loaded
on your machine. When a video is played from Visual Basic, a new window is opened
with the title of the video file shown. When the video is complete, the window
is automatically closed.
• The DLL function mciExecute is used to play video files (note it will
also play WAV files). The syntax for using this function is:
Dim RtnValue as Long .
RtnValue = mciExecute (Command
where Command is a string argument consisting of the keyword ‘Play’
concatenated with the complete pathname to the desired file.
Quick Example 12 - Multimedia
Sound and Video
Start a new application. Add a command button and a common dialog box. Copy
and paste the mciExecute Declare statement from the API Text Viewer program into
your application. It should read:
Private Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand
As String) As Long
Add this code to the Command1_Click procedure:
Private Sub Command1_Click()
Dim RtnVal As Long
'Get name of .avi file to play
CommonDialog1.Filter = "Video Files|*.avi"
RtnVal = mciExecute("play " + CommonDialog1.filename)
Run the application. Find a AVI file and see and hear the lovely results.