|
|
![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
Controlling The Multimedia Control From CodeThe multimedia control displays buttons for the user to control whats going on with a particular multimedia device, but there are times when you dont want the control to be visible. For example, you may want to play sounds under program control using the multimedia control, in which case you dont want your multimedia control to be visible. In such a case, you should issue commands to the control directly using its Command property.
Every action that you can perform with a multimedia control you can perform with the Command property. Here are the possible commands that you set (as text strings) in the Command property:
Lets see an example. Here, we open and play the file C:\windows\media\ding.wav (which comes with Windows) when a form loads, using the Open and Play commands: Private Sub Form_Load() MMControl1.Notify = False MMControl1.Wait = True MMControl1.Shareable = False MMControl1.FileName = "C:\WINDOWS\MEDIA\DING.WAV" MMControl1.Command = "Open" MMControl1.Command = "Play" End Sub If you dont want the multimedia control in this code, MMControl1, to be visible, set its Visible property to False. Stopping And Pausing The Multimedia ControlThe Testing Department is calling again. Beethovens Fifth Symphony is really fine, but does your program have to play it continuously? You explain that you like Beethoven. Fine, they say, add Stop and Pause buttons to your program. Although the multimedia control has Stop and Pause buttons, those buttons wont be accessible if youre running the control from code and have made the control invisible. To stop the control, you can set its Command property to Stop this way:
Private Sub Stop_Click()
MMControl1.Command = "Stop"
End Sub
To pause the control, you set the Command property to Pause:
Private Sub Pause_Click()
MMControl1.Command = "Pause"
End Sub
Executing this line of code if the control is paused makes it try to resume again, but note that many devices dont support pause and resume. For example, if youre using the computers CD-ROM drive to play music and try to pause it, youll find that most drives stop and the multimedia controls Mode property (see the next topic in this chapter) will be set to mciModeStop, not mciModePause. If you try to resume the CD-ROM music with another Pause command, nothing will happenyou have to use the Play command to restart playback.
|
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. |