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
Lets see an example. Here, we set the Notify property of a multimedia control, MMControl1, to True, then open a WAV file:
Private Sub Form_Load()
MMControl1.Notify = True
MMControl1.FileName = "C:\WINDOWS\MEDIA\DING.WAV"
MMControl1.Command = "Open"
...
End Sub
Then we add code to the Done event to display the error message for the current error, if there is one, using the Error and ErrorMessage properties:
Private Sub MMControl1_Done(NotifyCode As Integer)
If MMControl1.Error <> 0 Then
MsgBox MMControl1.ErrorMessage
End If
End Sub
Now, if we execute an illegal command, well be notified of the fact. For example, we might try to eject the WAV file, which is an illegal multimedia operation:
Private Sub Form_Load()
MMControl1.Notify = True
MMControl1.FileName = "C:\WINDOWS\MEDIA\DING.WAV"
MMControl1.Command = "Open"
MMControl1.Command = "Eject"
End Sub
In this case, we get the error message you see in Figure 22.7.
Figure 22.7 A multimedia control error message.
Stepping A Multimedia Control Forward Or Backward Frame By Frame
The Testing Department is calling again. Your program that plays the inspirational speech by the companys founder is a big hitbut cant you let the user move through it frame by frame for more impact? Hmm, you think, how do you do that?
You can use the Step and Back multimedia control commands to step through animations frame by frame. Each time you use these commands, you move forward or back by the number of frames set in the Frames property (the default is 1). To check if a multimedia control is connected to a device that can step this way, check the CanStep propertyif its set to True, you can use the Step and Back commands.
Lets see an example. We might connect a multimedia control, MMControl1, to a picture box, Picture1 this way so that it plays the file C:\windows\help\scroll.avi (which comes with Windows):
Private Sub Form_Load()
MMControl1.FileName = "C:\windows\help\scroll.avi"
MMControl1.hWndDisplay = Picture1.hWnd
MMControl1.Command = "Open"
End Sub
Now when the user clicks a command button, Command1, we will advance MMControl1 by, say, five frames (after checking to make sure it can step):
Private Sub Command1_Click()
If MMControl1.CanStep Then
MMControl1.Frames = 5
MMControl1.Command = "Step"
End If
End Sub
When the user clicks another button, Command2, we can step back five frames:
Private Sub Command2_Click()
If MMControl1.CanStep Then
MMControl1.Frames = 5
MMControl1.Command = "Back"
End If
End Sub
Thats itnow the user can step forwards and backwards in the animation.
Starting From And To In A Multimedia Control
The Testing Department is calling again. The sound file you play in the opening screen of your new program, SuperDuperMultimedia4U, is 10 minutes long. Yes, you say, but its a good one. Cant you play just part of it? they ask.
You can specify the start and end point of play and record multimedia operations with the From and To properties. You set these properties in the same time format youve specified in the multimedia controls TimeFormat property (see Setting a Multimedia Controls Time Format earlier in this chapter).
Lets see an example. In this case, well just play the first 10 seconds of a MID file, C:\windows\media\canyon.mid, which comes with Windows. First, we open that file when the form first loads, using a multimedia control, MMControl1, and set the controls time format to mciFormatMilliseconds:
Private Sub Form_Load()
MMControl1.TimeFormat = mciFormatMilliseconds
MMControl1.FileName = "c:\windows\media\canyon.mid"
MMControl1.Command = "Open"
End Sub
Now, when the user clicks a command button, Command1, we play the first 10 seconds of the file like this (although weve set the controls time format to mciFormatMilliseconds, times in this format are actually measured in tenths of a second, which means that we set to From property to 100 for 10 seconds):
Private Sub Command1_Click()
MMControl1.From = 0
MMControl1.To = 100
MMControl1.Command = "Play"
End Sub
And thats itnow you can set the To and From locations in a multimedia file.
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:
768 803770 772770 772mbdch20 770mbdch20 768769 770767 768BEYERDYNAMIC DT 770 PRO770 772770 772764 768więcej podobnych podstron