Visual Basic Concepts
Multimedia Control Scenario: Creating a Simple Audio CD Player
Using a few of the techniques discussed in the section, "Using the Multimedia Control," you can create a simple audio CD player application that illustrates features of the Multimedia control. This scenario uses one form and one instance of the Multimedia control and assumes that both an audio CD-compatible CD-ROM drive and a sound card are installed in the computer.
To begin, start a new project in Visual Basic. Add an instance of the Multimedia control to the form. In the form's Form_Load event procedure add the following code:
'Set initial property values of the media device
Form1.MMControl1.Notify = False
Form1.MMControl1.Wait = True
Form1.MMControl1.Shareable = False
Form1.MMControl1.DeviceType = "CDAudio"
'Open the media device
Form1.MMControl1.Command = "Open"
Opening the MCI device in the Form_Load procedure initializes the device at run time. If an audio CD is loaded into the CD drive, the appropriate buttons on the Multimedia control are enabled.
A simple audio CD player
The Multimedia control recognizes what actions are relevant for the current state of a device. Therefore, the appropriate buttons are automatically enabled when supported MCI devices are opened with the Multimedia control. In this example, when the Play button is pressed, the Stop and Pause buttons are enabled. If the CD is removed from the CD drive while the application is running, all the buttons become disabled.
Sample Application: MCITest.vbp
The MCITest.vbp sample application, which is listed in the directory, builds on this scenario and provides you with advanced programming techniques using the Multimedia control.