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 Controls Status
The Testing Department is calling again. Your multimedia program, SuperDuperSounds4U, is terrific, but how about a control panel that shows the current operationplay, 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:
mciModeNotOpen524; device is not open
mciModeStop525; device is stopped
mciModePlay526; device is playing
mciModeRecord527; device is recording
mciModeSeek528; device is seeking
mciModePause529; device is paused
mciModeReady530; device is ready
As you can see, the Mode property tells you whats going on with the multimedia controlbut when do you use the Mode property? You usually use that property in the multimedia controls 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.
Lets see an example. Here, well 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 controls 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 thats elapsed in the current operation. Lets 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 thats elapsed from the beginning of the file, displaying that time in a label, Label1. Although weve set the time to milliseconds, its actually only reported in tenths of a second (probably because the computers 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 youre 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, its 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 youre recording data with the multimedia controls Record command, you should use the Save command before closing the control to save the recorded data to disk (in the file whose name youve 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 750pacjenciid&753Kartridże atramentowe Xerox M 750Agroxone Max 750 SLNUM 750 D900 12mMagnat Maximus1 750 car ampReadMe (753)ZASOBNIK MULTI 750 0Cin Arrow 750 [DFM] MT60 89 1DEC RADY WE 750 2000Lotus 750 ECEsab Auto Path 750 CNC M552 81więcej podobnych podstron