747 750




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




Controlling The Multimedia Control From Code
The multimedia control displays buttons for the user to control what’s going on with a particular multimedia device, but there are times when you don’t 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 don’t want your multimedia control to be visible. In such a case, you should issue commands to the control directly using its Command property.

TIP:  If you really just want to play sounds under program control, you can avoid the heavy drain on system resources by interfacing directly to Windows to play sounds instead of using a multimedia control. See “Multimedia Without Multimedia Controls” near the end of this chapter.

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:

•  Open—Opens a device using the MCI_OPEN command. Uses the DeviceType and/or FileName properties.
•  Close—Closes a device using the MCI_CLOSE command.
•  Play—Plays a device using the MCI_PLAY command. Can use the From and To properties if they are set.
•  Pause—Pauses playing or recording using the MCI_PAUSE command. If executed while the device is paused, tries to resume playing or recording using the MCI_RESUME command.
•  Stop—Stops playing or recording using the MCI_STOP command.
•  Back—Steps backward using the MCI_STEP command. Uses the Frames property.
•  Step—Steps forward using the MCI_STEP command. Uses the Frames property.
•  Prev—Goes to the beginning of the current track using the Seek command. If executed within three seconds of the previous Prev command, it goes to the beginning of the previous track or to the beginning of the first track if at the first track.
•  Next—Goes to the beginning of the next track (if at the last track, it goes to beginning of the last track) using the Seek command.
•  Seek—If not playing, seeks a position using the MCI_SEEK command. If playing, continues playing from the given position using the MCI_PLAY command. Can use the To property if set.
•  Record—Records using the MCI_RECORD command. Can use the From and To properties if they are set.
•  Eject—Ejects media using the MCI_SET command.
•  Sound—Plays a sound using the MCI_SOUND command. Uses the FileName property.
•  Save—Saves an open file using the MCI_SAVE command. Uses the FileName property.

Let’s 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 don’t want the multimedia control in this code, MMControl1, to be visible, set its Visible property to False.
Stopping And Pausing The Multimedia Control
The Testing Department is calling again. Beethoven’s 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 won’t be accessible if you’re 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 don’t support pause and resume. For example, if you’re using the computer’s CD-ROM drive to play music and try to pause it, you’ll find that most drives stop and the multimedia control’s 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 happen—you have to use the Play command to restart playback.



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
Kartridże atramentowe Xerox M 750
747 SHEET 2 tiled 8 5X11
Agroxone Max 750 SL
NUM 750 D900 12m
747 a
mbdch20 747
Magnat Maximus1 750 car amp
747 749
ZASOBNIK MULTI 750 0
Cin Arrow 750 [DFM] MT60 89 1

więcej podobnych podstron