The Multimedia Control

Despite its power, the multimedia control is extremely simple to use. You'll write only a small amount of code to use the it. With the multimedia control, you'll be able to embed objects that represent the following simple multimedia devices:

  • CD audio player (CDAudio)
  • Digital audio tape player (DAT)
  • Digital video files (DigitalVideo)
  • Overlay (Overlay)
  • Scanner (Scanner)
  • Videotape player and recorder (Vcr)
  • Videodisc player (Videodisc)
  • Other devices not specified, supported by third-party drivers (Other)

note

The values in parentheses are used in the multimedia control's DeviceType property, as described in the next section.

You can also embed objects that represent the following compound multimedia devices:

  • The audio file player and recorder plays and records waveform files (files that have the .WAV extension).
  • The MIDI sequencer plays Musical Instrument Digital Interface files (files that have the .MID extension).
  • The video file player and recorder plays and records Audio Visual Interleave video files (files that have the .AVI extension).

note

A simple multimedia device requires no file associated with the control. For example, no file is associated with an audio CD you insert in your CD-ROM drive to listen to; the CD contains the music and no file is necessary. A compound multimedia device requires an extra file for the data, such as an audio file player that needs a WAV file to know which sounds to make.

Obviously, the PC on which your multimedia applications run must support standard multimedia devices, such as sound, graphics, and video, as well as have a CD-ROM drive (or a compatible device, such as a DVD drive).

Applying the Control

As with the common dialog box control, you must add the multimedia control to your toolbox window, because the standard toolbox does not list the multimedia control. To do this, press Ctrl+T to display the Components dialog box and select the control labeled Microsoft Multimedia Control 6.0. When you click OK, Visual Basic adds the control as the last tool on your toolbox window.

When you place the multimedia control on a form, a familiar set of buttons appear: These buttons mimic the ones that control your VCR or cassette tape player (see Figure 14.8).

Figure 14.8

The multimedia control produces this set of multimedia device buttons.

The multimedia control is an intelligent control that recognizes the capabilities of the devices you attach to it. Therefore, the Play button will not be active if you've ejected a CD from the CD-ROM drive. Of course, you have complete control, through various property value settings, over which buttons appear on the control. Instead of having an inactive Record button appear on the multimedia control when playing audio CDs (which cannot be recorded over), you'll want to completely hide the Record button.

note

The multimedia control provides information to your application about the device and its current settings. For example, your application can display the track numbers on an audio CD as the CD plays in the drive.

The multimedia control contains a list of devices with preselected buttons, so you don't have to specifically select individual buttons to appear on each control. The multimedia control supports a property called DeviceType that, when you initialize it with the device you want to use (such as the value of CDAudio, which specifies that you want the multimedia control to control an audio CD), the multimedia control automatically enables the correct buttons. The list of supported devices presented at the beginning of the previous section lists all the values allowed in the DeviceType property. Your job is to tell the application that the multimedia control is to be a CD audio player; then the multimedia control takes care of setting up the correct buttons.

As with many of the more involved controls, such as the common dialog box control, the multimedia control includes a (Custom) entry in the Properties window that you can select to display a dialog box that simplifies selecting properties. For example, if you click the Controls tab, the dialog box page shown in Figure 14.9 appears. From here, you can customize exactly which buttons appear on the control. You can also check if you want to display or enable any button on the control.

Figure 14.9

The Properties window's (Custom) entry makes selecting properties, such as the visible buttons, simple.

note

The multimedia control automatically makes all buttons visible but disabled until you enable one or more of the buttons, or until you select a DeviceType value that determines the button collection the multimedia control is to enable and display.

Top Home