742 745




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




Immediate Solutions
Using The Animation Control
Visual Basic comes with an animation control, and we’ll start our multimedia operations by taking a look at this control. This control is smaller than the multimedia control and takes up fewer system resources, but it’s very restricted. The animation control can only play AVI files, and those without sound at that. In addition, the animation control can display only uncompressed AVI files or AVI files that have been compressed using run-length encoding (RLE).


WARNING!  The animation control is pretty picky: if you try to load an AVI file into an animation control that includes sound data or that is in a format not supported by the control, an error (error 35752) is returned.

This control is useful because you can play AVI files in it directly, without using another control (for example, the multimedia control uses a picture box to play animations). The control allows you to create buttons or other objects that display animations when clicked. For example, the File Copy progress bar in Windows 95 uses an animation control; as you’ve probably seen, pieces of paper “fly” from one folder to another while the copy operation is in progress, and that’s supported with an animation control.

Here’s how you add an animation control to a program:

1.  Select the Project|Components menu item.
2.  Click the Controls tab in the Components dialog box that opens.
3.  Select the entry labeled Microsoft Windows Common Controls-2, and click on OK to close the Components dialog box.
4.  The previous steps add the Animation Control tool to the Visual Basic toolbox; draw the control as you like in your program.

To display an AVI file, you use the control’s Open method to open that file, passing the file name as the single argument to Open. After you’ve opened the file to play, you can use the Play method to play the file:


AnimationControl.Play ([ varRepeatCount] [,varStartFrame] [,varEndFrame])


You can also set the control’s AutoPlay property to True to make the control play the AVI file as soon as it opens that file. Here’s an example in which we set AutoPlay to True for an animation control, Animation1:


Private Sub Command1_Click()
Animation1.AutoPlay = True
...
End Sub


Then we open and play an AVI file, animation3.avi:



Private Sub Command1_Click()
Animation1.AutoPlay = True
Animation1.Open "animation3.avi"
End Sub


The animation control is relatively lightweight, so you can add it to your programs without taking up many system resources, but the limits of this control are severe. If you want to play AVI files with sound or other types of files, look into the multimedia control topics coming up in this chapter.

Adding A Multimedia Control To A Program
The Aesthetic Design Department is calling again. Users of your program, SuperDuperDataCrunch, get pretty tense around tax time while computing their taxes using that program. Wouldn’t it be great if your program could play some soothing music in the background? Well, you say dubiously, if you really want to.
You can let your program play sounds (WAV files, MID files, or even the CD in the computer’s CD drive) using the multimedia control, and we’ll see how to add that control to a program now. Just follow these steps:

1.  Select the Project|Components menu item.
2.  Click the Controls tab in the Components dialog box that opens.
3.  Select the entry labeled Microsoft Multimedia Control, and click on OK to close the Components dialog box.
4.  The previous steps add the Multimedia Control tool to the Visual Basic toolbox; draw the control as you like in your program.
5.  The multimedia control can be oriented horizontally or vertically—to orient it horizontally (the default), set the control’s Orientation property to mciOrientHorz (0); to orient it vertically, set it to mciOrientVertical.
6.  Set the control’s DeviceType, FileName, and TimeFormat properties as needed—see the following topics in this chapter.

Now that you’ve added a multimedia control to your program, see the following few topics on how to configure and use it in code.

Setting The Device Type And Opening The Device
Now that you’ve added a multimedia control, how do you indicate what kind of multimedia device you want to open? And how do you open it? Does opening the device make the buttons in the multimedia control active?

You can use the control’s DeviceType property to set the type of device you want to work with. You set this property when you’re opening an actual device such as a CD drive, or when the name of the file you’re working with (see the following topic, “Setting File Information”) does not indicate the format of the multimedia data. Note that you do not need to set the DeviceType property when playing files in recognized file formats like WAV, MID, AVI, MPG, and so on.
Here are the different strings you can set the DeviceType property to, one for all the device types the multimedia control supports:

•  AVIVideo
•  CDAudio
•  DAT
•  DigitalVideo
•  MMMovie
•  Other
•  Overlay
•  Scanner
•  Sequencer
•  VCR
•  Videodisc
•  WaveAudio

You set the DeviceType property before opening the device with the Open command. To use the Open command, you set the multimedia control’s Command property to “Open”.
Let’s see an example. Here, we open a music CD in the computer’s CD-ROM drive, connecting it to the multimedia control MMControl1 when in the Form_Load event and then opening that device:


Private Sub Form_Load()
MMControl1.TimeFormat = MCI_FORMAT_TMSF
MMControl1.DeviceType = "CDAudio"
MMControl1.Command = "Open"
End Sub


If there is a CD in the CD drive, the multimedia control’s buttons become active after executing this code and the user can play the CD (if your version of Windows has AutoPlay enabled, you might have to hold down the shift key while inserting the CD to make sure the Windows CD player does not come up automatically).




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:
745 755
745 746
mbdch20 745
mbdch20 742
742[01] o1 04 u magazynowanie materiałów i wyrobów
95 4310 745 000 2006 Tora Service Guide
742[01] z1 01 u ręczna obróbka drewna
641 745
745 2003 petrol YES
745 a

więcej podobnych podstron