750 753




Visual Basic 6 Black Book:Multimedia
function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) { var end = document.cookie.indexOf (";", j); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(j, end)); } i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } var m1=''; var gifstr=GetCookie("UsrType"); if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; } document.write(m1+m2+m3);            Keyword Title Author ISBN Publisher Imprint Brief Full  Advanced      Search  Search Tips Please Select ----------- Components Content Mgt Certification Databases Enterprise Mgt Fun/Games Groupware Hardware IBM Redbooks Intranet Dev Middleware Multimedia Networks OS Prod Apps Programming Security UI Web Services Webmaster Y2K ----------- New Titles ----------- Free Archive 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 function isIE4() { return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') ); } function bookMarkit() { var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0"; parent.location.href=url; //var win = window.open(url,"myitk"); //if(!isIE4()) // win.focus(); } Search this book:  














Previous
Table of Contents
Next




Displaying The Multimedia Control’s Status
The Testing Department is calling again. Your multimedia program, SuperDuperSounds4U, is terrific, but how about a control panel that shows the current operation—play, stop, pause, and so on? Hmm, you think, how can you do that?
You can use the Mode property to determine the current operation in a multimedia control. Here are the possible values for that property:

•  mciModeNotOpen—524; device is not open
•  mciModeStop—525; device is stopped
•  mciModePlay—526; device is playing
•  mciModeRecord—527; device is recording
•  mciModeSeek—528; device is seeking
•  mciModePause—529; device is paused
•  mciModeReady—530; device is ready

As you can see, the Mode property tells you what’s going on with the multimedia control—but when do you use the Mode property? You usually use that property in the multimedia control’s StatusUpdate event handler. The StatusUpdate event occurs at regular intervals as specified in the UpdateInterval property (this property is set in milliseconds). You can take advantage of the StatusUpdate event to keep the user appraised of the status of multimedia operations.
Let’s see an example. Here, we’ll display the status of a multimedia control, MMControl1, in a label control, Label1. We start with a Select Case statement in the StatusUpdate event handler, which uses the control’s Mode property as the selection criterion:


Private Sub MMControl1_StatusUpdate()
Select Case MMControl1.Mode
...
End Select

End Sub


Now we check for the various possible multimedia operations by setting up case statements for possible values of the Mode property:


Private Sub MMControl1_StatusUpdate()
Select Case MMControl1.Mode

Case mciModeReady

Case mciModeStop

Case mciModeSeek

Case mciModePlay

Case mciModeRecord

Case mciModePause

End Select

End Sub


Next we set up a string, strMode, to hold the current multimedia mode, and display that mode in a label control in the program, Label1, this way:


Private Sub MMControl1_StatusUpdate()
Dim strMode As String
strMode = ""

Select Case MMControl1.Mode

Case mciModeReady
strMode = "Ready."

Case mciModeStop
strMode = "Stopped."

Case mciModeSeek
strMode = "Seeking."

Case mciModePlay
strMode = "Playing."

Case mciModeRecord
strMode = "Recording."

Case mciModePause
strMode = "Paused."

End Select

Label1.Caption = strMode

End Sub


Adding this code to a multimedia control program, such as the CD player program in Figure 22.2 (this program is developed later in this chapter), indicates to the user the current status of that control.


Figure 22.2  Showing the status of the multimedia control.
You can also display the time that’s elapsed in the current operation. Let’s see an example. Here, we set the time format in a multimedia control that opens the file C:\windows\media\canyon.mid (which comes with Windows) to mciFormatMilliseconds:


Private Sub Form_Load()
MMControl1.TimeFormat = mciFormatMilliseconds
MMControl1.FileName = "c:\windows\media\canyon.mid"
MMControl1.Command = "Open"
End Sub


Then we can report where we are in the MID file with the StatusUpdate event and the Position property, which holds the time that’s elapsed from the beginning of the file, displaying that time in a label, Label1. Although we’ve set the time to milliseconds, it’s actually only reported in tenths of a second (probably because the computer’s Timer event can only occur 18.2 times a second), so we display the current time in the MID file this way:


Private Sub MMControl1_StatusUpdate()
Label1.Caption = Str(MMControl1.Position / 10)
End Sub


Closing The Multimedia Control
When you’re finished with the multimedia control, you usually close it, typically in the Form_Unload event. Here, for example, we close the multimedia control when the form unloads using the Close command:


Private Sub Form_Unload (Cancel As Integer)
MMControl1.Command = "Close"
End Sub


In fact, it’s a good idea to execute a Stop command before closing the control, because closing the control does not necessarily stop operations like audio playback (for example, your CD will keep playing even if you exit your multimedia control CD player program, unless you explicitly stop the CD):


Private Sub Form_Unload (Cancel As Integer)
MMControl1.Command = "Stop"
MMControl1.Command = "Close"
End Sub



TIP:  If you’re recording data with the multimedia control’s Record command, you should use the Save command before closing the control to save the recorded data to disk (in the file whose name you’ve specified in the FileName property).





Previous
Table of Contents
Next






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.



Wyszukiwarka

Podobne podstrony:
SUZUKI GSXR 600 750
pacjenciid&753
Kartridże atramentowe Xerox M 750
Agroxone Max 750 SL
NUM 750 D900 12m
Magnat Maximus1 750 car amp
ReadMe (753)
ZASOBNIK MULTI 750 0
Cin Arrow 750 [DFM] MT60 89 1
DEC RADY WE 750 2000
Lotus 750 EC
Esab Auto Path 750 CNC M552 81

więcej podobnych podstron