|
|
 |
 |
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98
Chapter 22 Multimedia
- If you need an immediate solution to:
- Using The Animation Control
- Adding A Multimedia Control To A Program
- Setting The Device Type And Opening The Device
- Setting File Information And Opening Files
- Setting A Multimedia Controls Time Format
- Controlling The Multimedia Control From Code
- Stopping And Pausing The Multimedia Control
- Displaying The Multimedia Controls Status
- Closing The Multimedia Control
- Playing CDs From Your CD-ROM Drive
- Playing WAV Files
- Playing MID Files
- Playing AVI Files
- Playing MPG Files
- Keeping Track Of Multimedia Command Execution Using Notification
- Handling Multimedia Errors
- Stepping A Multimedia Control Forward Or Backward Frame By Frame
- Starting From And To In A Multimedia Control
- Making The Multimedia Control Wait
- Multimedia Without Multimedia Controls
-
In Depth
Multimedia has become a hot topic in recent years, and rightly so. Programs with interactive sound, images, and animations can be very effectivemore so than static onesand computers are increasingly well equipped to handle multimedia.
What do we mean by multimedia? For the purposes of this chapter, multimedia refers to supporting sound and animated images. There are endless devices and programs to work with multimedia, ranging from simple programs that can display simple animations to VCR and videodisc players and advanced MIDI devices. Visual Basic provides a great deal of multimedia support, and that support is wrapped up in the multimedia control. This chapter is about the multimedia control, although well also see a few additional techniques, such as using the animation control and interacting with Windows directly to support multimedia.
The Multimedia MCI Control
The multimedia MCI control well use in Visual Basic manages the recording and playback of multimedia files on Media Control Interface (MCI) devices. This control issues commands to devices like audio boards, MIDI sequencers, CD-ROM drives, audio CD players, videodisc players, videotape recorder/players, and more. The multimedia control also lets you play WAV and MID sound files and display video files like AVI and MPG.
The actual control displays a bar of buttons, as shown in Figure 22.1. The buttons are named Prev, Next, Play, Pause, Back, Step, Stop, Record, and Eject, in that order. As you can see, the multimedia control is designed to let the user control multimedia presentations, rather than present them itself.
Figure 22.1 The Visual Basic multimedia control.
To use the multimedia control, your application should already have the MCI device open (and the appropriate buttons in the multimedia MCI control enabled) before the user chooses a button in the control. To make sure a device is open, you usually place the MCI Open command in the Form_Load event.
Using The Multimedia Control From Code
The multimedia control can be visible or invisible at runtime, and if its invisible, you can use it in code. If the control is visible, the user can click buttons to operate the control; if the control is invisible, you can use it from your programs code by using its Command property to execute Open, Play, Record, Close, and other commands. In this way, you can play audio and display video (in controls like picture boxes) even though the user doesnt know youre using a multimedia control.
From code, you set various properties of the multimedia control, such as the time format the device uses, the file it is to open and play or record to, and other aspects, as well see in this chapter.
You can keep track of the multimedia control through two events, the Done event and the StatusUpdate event. The Done event is fired to indicate that various multimedia operations are completed (if you have set the controls Notify property to True), and the StatusUpdate property occurs when the status of the control changes (such as when the user clicks the Play button and the controls begins playback). The Done event handler is passed a notification code that you can check, and in the StatusUpdate event handler, you can check the controls Mode property to see if the control is playing, is paused, is stopped, and so forth. You can also redefine the buttons in a multimedia control in code if you want to by developing code for the controls button events, which occur when the user clicks a button.
TIP: When you create and distribute applications that use the multimedia MCI control, you should install and register the appropriate files in the customers Microsoft Windows System (or System32 directory). The Package and Deployment Wizard included with Visual Basic (see Chapter 30) provides tools to help you write setup programs that install your applications correctly.
Thats it for the overview of multimedia for the moment. Its time to turn to our Immediate Solutions.
|