I. Foreword With the continuous improvement of multimedia hardware environment and software environment, most of the computer software development involves the application of multimedia software technology. Multimedia application design, as in principle, you can use a variety of tools such as C to multimedia-specific development systems such as Toolbook, Authorware, Director. However, since the media is complex and diverse, the development cycle is short and requires a variety of professionals to participate, so in order to perform practical and efficient development, it is necessary to use software that is simple and easy to use and high development efficiency. Visual Basic is the Windows programming tool software developed by Microsoft. Since it has advanced design ideas, it is very flexible and diverse, and the media object means is flexible, and it has received the attention and favor of multimedia software developers, and therefore becomes an ideal tool for multimedia applications.
Second, Visual Basic multimedia control MCI.OCX
MCI (Media Control Interface) is a media control interface standard that Microsoft provides media control interfaces provided by devices under Windows systems. Users can easily use MCI control standard multimedia devices.
The MCI is included in the Windows multimedia extension MMSystem module to coordinate events and communication between the MCI device drivers, providing interface properties that are independent of the device. Usually the application is distinguished by specifying an MCI device type, and the device type indicates the physical type of the current actual use of the device. Different device types use different control properties to describe (see Schedule 1).
From the control method used, MCI devices are divided into composite and simple two categories. A simple MCI device does not require device elements. For example, the CD audio and vault operates in a hard disk that has been installed, and they do not need to provide any information for their operations. But for the composite MCI device, the application provides device elements, namely a source data file or destination file containing all path names.
Visual Basic language Custom Control (User Control Components) Concept reflects the development trend of today's software - object-oriented technology, programmers can embed a variety of five hundred user controls in Visual Basic toolbox (Toolbox), each The user control components have certain attributes and operation methods, and the programmer completes a specific function through the control of the settings and methods of the attribute. In order to facilitate multimedia, a user control for multimedia purposes - MCI.OCX is provided in the Professional Visual Basic Toolbox.
Multimedia MCI Control MCI.ocx is dedicated to multimedia data files for multimedia control interface MCI devices. From the purpose of the purpose, the control passes a set of buttons to implement various equipment control commands to implement, such as: audio panel, MIDI Channel control of sequencer, CD-ROM drive, audio CD player, video tape play, and recording. When the Visual Basic program is designed, when the multimedia MCI control is added in the table (double-click the MCI control in the toolbox), the following button group appears: forward (prev), backward (next), playback (play), pause (PAUSE), return (STEP), stop (STOP), record (RECORD) and Eject.
The application to MCI's set of buttons is very flexible. If we open an MCI device, you can select the appropriate status button from the control from the control according to the property of the device type, indicating the physical state of the instant device. All MCI controls can be programmed in the following ways: (1) Controls and their respective buttons; (2) variable or completely redefined the control; (3) Multiple devices can be controlled simultaneously in one window table. Third, Multimedia Control Components MCI.OCX In Visual Basic 3.0.0, multimedia control MCI.OCX (in Visual Basic 3.0 and 4.0, the extension of multimedia controls is .vbx) is provided as an optional part. In order to use it, first to execute the FileAdd File menu command, add the MCI.ocx under the WindowsSystem directory to Toolbox, which will appear in the toolbox. The corresponding MCI.OCX icon. If you are using a Visual Basic4.0 (or version 5.0), select the OOLSCUSTOM Controls menu or directly type Ctrl T, you can display the dialog box, select the check box next to the Microsoft MultiMedia Controls entry in the Available Controls list box, the same The MCI.ocx icon appears in the toolbox. Double-click the multimedia control MCI.ocx icon in the toolbox, then call the mci.ocx control, a row of gray media control buttons (nine) will appear in the form FORM.
Fourth, Visual Basic Multimedia Application Design Step Multimedia Control MCI.ocx contains a set of advanced control commands that are unrelated to devices. When using this multimedia control, first open the MCI device (multimedia device) and create a file with the corresponding file to perform records or putting operations (but the corresponding files such as CDAUDIO, VCR, and video tapes). Once the device is successful, you can issue a variety of operational commands (see the attached button command) to complete the specified job task. Finally, remember that use the close command to turn off the device and data files. It is convenient to develop multimedia applications using MCI.oCX, because most properties are easy to understand, where the Command property is especially important, which is commanded to multimedia devices during operation. The format is: form.mmControl.command = cmdstring $, cmdstring $ variable is the following executable command name: Open, Close, Play, Pause, Stop, Back, Step, Prev, Next, Seek, Record, Eject, Sound, SAVE . Once the command is set, it will execute immediately, and the error that happens exists in an Error property. The following is to play the Demo.wav (Waveform file) file as an example, indicating that the Visual Basic multimedia application design step. First, create a form (form) containing multimedia control (mci.ocx), so that the shape is displayed on the screen similar to the recorder, but the multimedia control component cannot be used immediately (all the keys are gray). The status of the key must be changed through the program code. Second, insert the corresponding program code during the Form_Load process. Following Sub Form_Load () 'before issuing the OPEN command to set the properties of the multimedia device Form1.MMControl1.Notify = False Form1.MMControl1.Wait = True Form1.MMControl1.Shareable = False Form1.MMControl1.DeviceType = "WaveAudio" Form1.MMControl1 .Filename = "c: windowss mmdataDeMo.v" form1.mmControl1.command = "open" end sub finally, run the above program, the control key is black, then you can use the Play, Record or the like to operate the data file demo.Wav . For example, use the mouse to press the PLAY button to hear the .WAV sound (computer should have a pronunciation device). Through the above statement, it is not difficult to find that Visual Basic uses multimedia control MCI.OCX to make povert 逵 τ trade? The order is easy to master.
V. Visual Basic Multimedia Application Design Example 1 Valley player. Table 1 shows the main control components definition of the simple CD player, which followed by the source code code corresponding to each trigger event. The full source program list is as follows: `CD Player Utility` Please load a laser player '"load" button in the CD-ROM drive before running the program Private submmand1_click () `Load CD Record on Error Goto MCI_ERROR MMControl1.Command = "Open" On Error GoTo 0 `set the time format MMControl1.TimeFormat = vbMCIFormatTmsf` close LOAD button to display the picture Command1.Enabled = False Picture1.Picture = Picture3.Picture `set the initial number of tracks Label1.Caption =" 1 "Exit Sub MCI_ERROR: DisplayErrorMessageBox Resume MCI_EXIT MCI_EXIT: Unload CD End SubPrivate Sub Form_Load () MMControl1.Wait = True MMControl1.UpdateInterval = 0` set the device type MMControl1.DeviceType = "CDAudio" `set the default track number is 0 Label1. CAPTION = "0" nd SUB
Private Sub Form_Unload (Cancel AS Integer) McITest.show End Sub
'' Tape-out 'button to trigger the event Private Sub MMControl1_EjectClick (Cancel As Integer) Command1.Enabled = True Picture1.Picture = Picture2.Picture MMControl1.UpdateInterval = 0 On Error GoTo MCI_ERROR2 MMControl1.Command = "Eject" MMControl1.Command = "Close "On Error Goto 0 label1.caption =" 0 "label3.backcolor = & h404040 exit sub mci_error2: DisplayErrorMessageBox Resume Next End Sub
'"Forward" button trigger event private Sub mmcontrol1_nextcompleted (ERRORCODE AS long) Label1.caption = Str $ (mmControl1.track) end sub
'"Pause" button Trigger Event Private Sub MMControl1_PauseClick (Cancel As Integer) MMControl1.UpdateInterval = 0 label3.backcolor = & H404040 End Sub
' "Play" button to trigger events Private Sub MMControl1_PlayClick (Cancel As Integer) MMControl1.UpdateInterval = 1000 Label1.Caption = Str $ (MMControl1.Track) End Sub' "back" button to trigger events Private Sub MMControl1_PrevCompleted (ErrorCode As Long) Label1 .Caption = Str $ (MMControl1.Track) End Sub Private Sub MMControl1_StatusUpdate () Label1.Caption = Str $ (MMControl1.Position And & HFF) If MMControl1.Mode = vbMCIModePlay Then Label3.BackColor = & H80FF & Else Label3.BackColor = & H404040 End If End Sub ' "stop" button triggering event Private Sub MMControl1_StopClick (Cancel As Integer) MMControl1.UpdateInterval = 0 Label3.BackColor = & H404040 MMControl1.To = MMControl1.Start MMControl1.Command = "Seek" MMControl1.Track = 1 Label1.Caption = "1" end SUB
2, play AVI (audio video interface) file movie (including sound and image) is one of the most concerned media information of the majority of computer workers, and film processing technology is also one of multimedia key technologies. In the multimedia system, AVI (Audio Video Interface, Audio Video Interface) file is a standard format that stores movies (including sounds and images), which are generally obtained by capturing real-time video signals, or by scanner acquisition Image or use animation software. Thus, the audio video operation on the screen window becomes the processing of the AVI file (file suffix AVI). In actual work, there are many ways to play AVI files (i.e., movies), and in which multimedia control methods that use Visual Basic are the most simple and convenient. The following is to explain how to play AVI files in a specific example: assume that the user's current directory has a video audio file with a demo.avi, then uses Visul Basic to play this video needs to pass the following steps: (1) in the form of Visual Basic Add a MMControl multimedia control, a PictureBox image box control, and two COMANDBUTTON command buttons; (2) Set the properties of each control, where the form is named Form1, the MMControl multimedia control is named mmControl1, the Picturebox picture box control is named Picture1, Two comandbutton command button controls are named play and close; (3) Write each trigger event source code and run. Source code: Private Sub Play_Click () MMControl1.Filename = "DEMO.AVI" MMControl1.DeviceType = = "AVIVIDEO" MMControl1.hWndDisplay = Picture1.hWnd MMControl1.Command = "OPEN" MMControl1.To = 1 MMControl1.Command = "Seek" mmcontrol1.command = "play" end sub private subclose_click () mmControl1.command = "stop" mmcontrol1.command = "close" End sub worth noting: Before playing the AVI file, first, AVI (audio) Video) The driver is installed under Windows. The AVI driver is named mciavi.drv, you must copy it to the WindowsSystem directory, while adding Windows when you are using: avivido = mciavi.drv in the system.ini file: avivideo = mciavi.drv, Windows will automatically use AVI The driver is installed. The above described only the operation procedure of playing audio file (.wav), CD record and audio video file (.avi) using multimedia control components. In fact, other media information such as animation files (.fli, .flc), MIDI files can be played using multimedia control components.
Sixth, the end language is not difficult to see by the previous discussion: Multimedia Control Components provided by Visual Basic MCI.OCX, the majority of computer users can develop a variety of multimedia applications. However, it is necessary to emphasize that developing the Visual Basic multimedia application, in addition to the multimedia control components, other means can be used, such as by calling API functions, etc. (in view of the space, not discussed here). It can be seen that Visual Basic is indeed a professional and non-professional multimedia software developers share the ideal development tools. Schedule 1 MCI device type definition device type device Description CDAUDIO laser record player DAT Digital Tape Audio Player DigitalVideo Digital Video Image Either Animation Animation Player Other No Standard Definition MCI Device SEQUENCE MIDI Sound Sequencing generator VCR can use the program-controlled disk recorder VIDEODISC can use the program-controlled laser video wheel Waveaudio to play digitized waveform audio equipment ???
Schedule 2 Multimedia Control Components Unique event list event Description Done completes the MCI command action (notify is true) ButtonClick Click the Button ButtonCompleted button to perform the button to get the button to get the input focus button, the statusUpidate update the status information of the media control object