View contents of this chapter

Playing Video Clips

In this section, you will learn how to play a video clip using the Multimedia control. The multimedia control requires a bit of help when playing video clips. Rather than use only a simple panel of buttons, you need a projection screen from which to show the video. The most common control to display videos with is the picture box control. Therefore, we will add a picture box control to every application that needs to display a video file. You tell the multimedia control the name of the picture box control in which to show the video in the multimedia control's hWndDisplay property.

hwnd is a common Windows programming prefix that represents a handle or, more accurately, a device context. In this example the program doesn't send video clip output to the screen, but to a device context.

Private Sub Form_Load()
   MMControl1.DeviceType = "AVIVideo"
   'connect the video player to the picture box
   MMControl1.hWndDisplay = picVideo.hWnd
   MMControl1.FileName = App.Path & "\COUNT.AVI"
   MMControl1.Command = "Open"
End Sub

Private Sub Form_Unload(Cancel As Integer)
   MMControl1.Command = "Close"
End Sub

Run the program to see the numbers in the video flash by (see the following figure)

Play Sound

Today's lesson explained how easy it is to spruce up your application with multimedia features. The multimedia control is one of the most comprehensive controls in Visual Basic, because it supports so many different kinds of multimedia devices. Your application can easily control audio Cds and sound files, and even play video.



© Universal Teacher Publications        INDEX Previous Screen Next Screen