VERSION 1.0 CLASS BEGIN MultiUse = -1 'True Persistable = 0 'NotPersistable DataBindingBehavior = 0 'vbNone DataSourceBehavior = 0 'vbNone MTSTransactionMode = 0 'NotAnMTSObject END Attribute VB_Name = "cMCI_Adv" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Option Explicit '============================================================================================================= ' ' cMCI_Adv Class Module ' --------------------- ' ' Created By : Kevin Wilson ' http://www.TheVBZone.com ( The VB Zone ) ' http://www.TheVBZone.net ( The VB Zone .net ) ' ' Last Update : January 8, 2002 ' ' VB Versions : 5.0 / 6.0 ' ' Requires : Sound Card ' ' Description : This module allows you to play, pause, stop, and manipulate any multimedia file that you have ' the drivers installed for. This module uses existing drivers to play multimedia files. So ' if you wanted to use this module to play a QuickTime movie file, you could as long as the ' user that is running your program has QuickTime installed on their computer. If you wanted to ' use this module to play MP3 files, you could as long as the user that is running your program ' has software installed to play MP3 files (like WinAmp). ' ' NOTE : I have successfully tested this module on Win9x and WinNT with the following media file formats: ' AIF, ASF, AU, AVI, WAV, MID, RMI, AVI, CDA, MP3, MPU, MOV, MPEG, WMA ' ' NOTE : Specifying "Other" as the device type will always work given the following 3 things are TRUE: ' 1) The file extention is included as part of the file path (tells it what type of file it is) ' 2) The file extention is the correct extention for the actual file type ' 3) There is a multimedia driver installed to handle the specified multimedia type ' '_____________________________________________________________________________________________________________ ' SEE ALSO: '¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ' ' MCI Overview ' http://msdn.microsoft.com/library/psdk/multimed/mci_7vvt.htm ' ' MCI Reference ' http://msdn.microsoft.com/library/psdk/multimed/mci_25k5.htm ' ' mciSendString Win32 API ' http://msdn.microsoft.com/library/psdk/multimed/mmfunc_5lrb.htm ' ' MCI Error Definitions ' http://msdn.microsoft.com/library/psdk/multimed/mmconst_3stv.htm ' ' MCI Device Types ' http://msdn.microsoft.com/library/psdk/multimed/mci_1k8j.htm ' ' Opening An MCI Device ' http://msdn.microsoft.com/library/psdk/multimed/mci_6oit.htm ' ' mciSendString - "open" Command ' http://msdn.microsoft.com/library/psdk/multimed/mmcmdstr_7226.htm ' ' mciSendString - "notify" Flag ' http://msdn.microsoft.com/library/psdk/multimed/mci_7xyf.htm ' ' MCI Command Strings ' http://msdn.microsoft.com/library/psdk/multimed/mci_04dv.htm ' ' MCI Error - "There is no driver installed on your system" ' http://support.microsoft.com/support/kb/articles/Q178/2/91.ASP ' ' MCI Example - CD Player ' http://support.microsoft.com/support/kb/articles/Q181/4/74.ASP ' ' MCI Example - Play AVI Fullscreen ' http://support.microsoft.com/support/kb/articles/Q171/9/81.asp ' '============================================================================================================= ' ' LEGAL: ' ' You are free to use this code as long as you keep the above heading information intact and unchanged. Credit ' given where credit is due. Also, it is not required, but it would be appreciated if you would mention ' somewhere in your compiled program that that your program makes use of code written and distributed by ' Kevin Wilson (www.TheVBZone.com). Feel free to link to this code via your web site or articles. ' ' You may NOT take this code and pass it off as your own. You may NOT distribute this code on your own server ' or web site. You may NOT take code created by Kevin Wilson (www.TheVBZone.com) and use it to create products, ' utilities, or applications that directly compete with products, utilities, and applications created by Kevin ' Wilson, TheVBZone.com, or Wilson Media. You may NOT take this code and sell it for profit without first ' obtaining the written consent of the author Kevin Wilson. ' ' These conditions are subject to change at the discretion of the owner Kevin Wilson at any time without ' warning or notice. Copyright© by Kevin Wilson. All rights reserved. ' '============================================================================================================= Private Type MIXERCONTROL cbStruct As Long dwControlID As Long dwControlType As Long fdwControl As Long cMultipleItems As Long szShortName As String * 16 'MIXER_SHORT_NAME_CHARS szName As String * 64 'MIXER_LONG_NAME_CHARS lMinimum As Long lMaximum As Long Reserved(10) As Long End Type Private Type MIXERLINECONTROLS cbStruct As Long dwLineID As Long dwControl As Long cControls As Long cbmxctrl As Long pamxctrl As Long End Type Private Type MIXERLINE cbStruct As Long dwDestination As Long dwSource As Long dwLineID As Long fdwLine As Long dwUser As Long dwComponentType As Long cChannels As Long cConnections As Long cControls As Long szShortName As String * 16 'MIXER_SHORT_NAME_CHARS szName As String * 64 'MIXER_LONG_NAME_CHARS dwType As Long dwDeviceID As Long wMid As Integer wPid As Integer vDriverVersion As Long szPname As String * 32 'MAXPNAMELEN End Type Private Type MIXERCONTROLDETAILS cbStruct As Long dwControlID As Long cChannels As Long item As Long cbDetails As Long paDetails As Long End Type 'Private Type MIXERCONTROLDETAILS ' cbStruct As Long 'DWORD ' dwControlID As Long 'DWORD ' cChannels As Long 'DWORD ' hwndOwner As Long 'HWND ' cMultipleItems As Long 'DWORD ' cbDetails As Long 'DWORD ' paDetails As Long 'LPVOID 'End Type Private Type MIXERCONTROLDETAILS_UNSIGNED dwValue As Long 'DWORD End Type Public Enum ResDataTypes rdt_Bitmap = 0 rdt_Icon = 1 rdt_Cursor = 2 rdt_String = 3 rdt_Data = 4 End Enum '_____________________________________________________________________________________________________________ ' Device Types Defined In The MSDN: ' ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ' CDAudio CD audio player ' DAT Digital-audio tape player ' DigitalVideo Digital video in a window (not GDI-based) ' AVIVideo (Same as digitalvideo) ' Overlay Overlay device (analog video in a window) ' Scanner Image scanner ' Sequencer MIDI sequencer ' VCR Video-cassette recorder or player ' VideoDisc Videodisc player ' WaveAudio Audio device that plays digitized waveform files ' MPEGVideo ActiveMovie/DirectShow player ' MPEGVideo2 ActiveMovie/DirectShow player ' Other Undefined MCI device '¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ Public Enum MciDeviceTypes ' See Also : http://msdn.microsoft.com/library/psdk/multimed/mci_8vxv.htm 'CD Audio Device (Basic MCI - Exists if a sound card has been installed on the user's computer) CDAudio = 1 'mcicda.drv - CDA 'Motion Video Device (Basic MCI - Exists if a sound card has been installed on the user's computer) '(NOTE : AVI-Video is also known as "Digital-Video") AVIVideo = 2 'mciavi.drv - AVI 'MIDI Sequencer Device (Basic MCI - Exists if a sound card has been installed on the user's computer) Sequencer = 3 'mciseq.drv - RMI, MID, MIDI 'Wave Audio Device (Basic MCI - Exists if a sound card has been installed on the user's computer) WaveAudio = 4 'mciwave.drv - WAV, WAVE 'ActiveMovie MCI Driver (Selective MCI - Exists if ActiveMovie/DirectShow have been installed on the user's computer) '(NOTE - If MSIE 4.01 or better have been installed on the user's computer, ActiveMovie was installed with it) MPEGVideo = 5 'mciqtz.drv / mciqtz32.dll - AIF, AIFC, AIFF, AU, DAT, M1V, MOV, M3U, MOV, MP2, MP2V, MP3, MPA, MPE, MPEG, MPG, MPV2, QT, SND MPEGVideo2 = 6 'mciqtz32.dll - ASF, ASX, IVF, RA, RAM, RM, RMM, WAX, WM, WMA, WMV, WVX 'VISCA VCR Device (Selective MCI - Exists if a VCR device or VCR software has been installed on the user's computer) VCR = 7 'mcivisca.drv 'PIONEER LaserDisc Device (Selective MCI - Exists if a LaserDisk/VideoDisc device or software has been installed on the user's computer) VideoDisc = 8 'mcipionr.drv 'Overlay device - Analog video in a window Overlay = 9 ' Other - Type is selected by the file extention other = 10 End Enum '-------------------------------------------- ' WAV Capture sizes based on replay settings: '-------------------------------------------- ' SPS: BPS: Channels: Size: '¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ' 8.000kHz 8bit Mono = 7 k/sec ' 8.000kHz 8bit Stereo = 15 k/sec ' 8.000kHz 16bit Mono = 15 k/sec ' 8.000kHz 16bit Stereo = 31 k/sec ' 11.025kHz 8bit Mono = 10 k/sec ' 11.025kHz 8bit Stereo = 21 k/sec ' 11.025kHz 16bit Mono = 21 k/sec ' 11.025kHz 16bit Stereo = 43 k/sec <-- GOOD DEFAULT ' 22.050Hz 8bit Mono = 21 k/sec ' 22.050Hz 8bit Stereo = 43 k/sec ' 22.050Hz 16bit Mono = 43 k/sec ' 22.050Hz 16bit Stereo = 86 k/sec ' 44.100Hz 8bit Mono = 43 k/sec ' 44.100Hz 8bit Stereo = 86 k/sec ' 44.100Hz 16bit Mono = 86 k/sec ' 44.100Hz 16bit Stereo = 172 k/sec '-------------------------------------------- Public Enum BitsPerSample bps_8bit = 8 bps_16bit = 16 End Enum Public Enum Channels Mono = 1 Stereo = 2 End Enum Public Enum SamplesPerSec sps_8000 = 8000 ' 8.000kHz sps_11025 = 11025 ' 11.025kHz sps_22050 = 22050 ' 22.050Hz sps_44100 = 44100 ' 44.100Hz End Enum ' Enumeration - MIXERLINE.dwComponentType Private Enum MixerComponentTypes MIXERLINE_COMPONENTTYPE_DST_DIGITAL = 1 ' Audio line is a digital destination (for example, digital input to a DAT or CD audio device). MIXERLINE_COMPONENTTYPE_DST_HEADPHONES = 5 ' Audio line is an adjustable (gain and/or attenuation) destination intended to drive headphones. Most audio cards use the same audio destination line for speakers and headphones, in which case the mixer device simply uses the MIXERLINE_COMPONENTTYPE_DST_SPEAKERS type. MIXERLINE_COMPONENTTYPE_DST_LINE = 2 ' Audio line is a line level destination (for example, line level input from a CD audio device) that will be the final recording source for the analog-to-digital converter (ADC). Because most audio cards for personal computers provide some sort of gain for the recording audio source line, the mixer device will use the MIXERLINE_COMPONENTTYPE_DST_WAVEIN type. MIXERLINE_COMPONENTTYPE_DST_MONITOR = 3 ' Audio line is a destination used for a monitor. MIXERLINE_COMPONENTTYPE_DST_SPEAKERS = 4 ' Audio line is an adjustable (gain and/or attenuation) destination intended to drive speakers. This is the typical component type for the audio output of audio cards for personal computers. MIXERLINE_COMPONENTTYPE_DST_TELEPHONE = 6 ' Audio line is a destination that will be routed to a telephone line. MIXERLINE_COMPONENTTYPE_DST_UNDEFINED = 0 ' Audio line is a destination that cannot be defined by one of the standard component types. A mixer device is required to use this component type for line component types that have not been defined by Microsoft Corporation. MIXERLINE_COMPONENTTYPE_DST_VOICEIN = 8 ' Audio line is a destination that will be the final recording source for voice input. This component type is exactly like MIXERLINE_COMPONENTTYPE_DST_WAVEIN but is intended specifically for settings used during voice recording/recognition. Support for this line is optional for a mixer device. Many mixer devices provide only MIXERLINE_COMPONENTTYPE_DST_WAVEIN. MIXERLINE_COMPONENTTYPE_DST_WAVEIN = 7 ' Audio line is a destination that will be the final recording source for the waveform-audio input (ADC). This line typically provides some sort of gain or attenuation. This is the typical component type for the recording line of most audio cards for personal computers. MIXERLINE_COMPONENTTYPE_SRC_ANALOG = 4106 ' Audio line is an analog source (for example, analog output from a video-cassette tape). MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY = 4105 ' Audio line is a source originating from the auxiliary audio line. This line type is intended as a source with gain or attenuation that can be routed to the MIXERLINE_COMPONENTTYPE_DST_SPEAKERS destination and/or recorded from the MIXERLINE_COMPONENTTYPE_DST_WAVEIN destination. MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC = 4101 ' Audio line is a source originating from the output of an internal audio CD. This component type is provided for audio cards that provide an audio source line intended to be connected to an audio CD (or CD-ROM playing an audio CD). MIXERLINE_COMPONENTTYPE_SRC_DIGITAL = 4097 ' Audio line is a digital source (for example, digital output from a DAT or audio CD). MIXERLINE_COMPONENTTYPE_SRC_LINE = 4098 ' Audio line is a line-level source (for example, line-level input from an external stereo) that can be used as an optional recording source. Because most audio cards for personal computers provide some sort of gain for the recording source line, the mixer device will use the MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY type. MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE = 4099 ' Audio line is a microphone recording source. Most audio cards for personal computers provide at least two types of recording sources: an auxiliary audio line and microphone input. A microphone audio line typically provides some sort of gain. Audio cards that use a single input for use with a microphone or auxiliary audio line should use the MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE component type. MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER = 4103 ' Audio line is a source originating from personal computer speaker. Several audio cards for personal computers provide the ability to mix what would typically be played on the internal speaker with the output of an audio card. Some audio cards support the ability to use this output as a recording source. MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER = 4100 ' Audio line is a source originating from the output of an internal synthesizer. Most audio cards for personal computers provide some sort of MIDI synthesizer (for example, an Adlib®-compatible or OPL/3 FM synthesizer). MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE = 4102 ' Audio line is a source originating from an incoming telephone line. MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED = 4096 ' Audio line is a source that cannot be defined by one of the standard component types. A mixer device is required to use this component type for line component types that have not been defined by Microsoft Corporation. MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT = 4104 ' Audio line is a source originating from the waveform-audio output digital-to-analog converter (DAC). Most audio cards for personal computers provide this component type as a source to the MIXERLINE_COMPONENTTYPE_DST_SPEAKERS destination. Some cards also allow this source to be routed to the MIXERLINE_COMPONENTTYPE_DST_WAVEIN destination. End Enum ' Constants - Window Sytles (Used in the mciSendString "open" command for the "Style_Type" parameter) Private Const WS_BORDER = &H800000 ' Creates a window that has a thin-line border. Private Const WS_CAPTION = &HC00000 ' Creates a window that has a title bar (includes the WS_BORDER style). Private Const WS_CHILD = &H40000000 ' Creates a child window. A window with this style cannot have a menu bar. This style cannot be used with the WS_POPUP style. Private Const WS_CLIPCHILDREN = &H2000000 ' Excludes the area occupied by child windows when drawing occurs within the parent window. This style is used when creating the parent window. Private Const WS_CLIPSIBLINGS = &H4000000 ' Clips child windows relative to each other; that is, when a particular child window receives a WM_PAINT message, the WS_CLIPSIBLINGS style clips all other overlapping child windows out of the region of the child window to be updated. If WS_CLIPSIBLINGS is not specified and child windows overlap, it is possible, when drawing within the client area of a child window, to draw within the client area of a neighboring child window. Private Const WS_DISABLED = &H8000000 ' Creates a window that is initially disabled. A disabled window cannot receive input from the user. To change this after a window has been created, use EnableWindow. Private Const WS_DLGFRAME = &H400000 ' Creates a window that has a border of a style typically used with dialog boxes. A window with this style cannot have a title bar. Private Const WS_GROUP = &H20000 ' Specifies the first control of a group of controls. The group consists of this first control and all controls defined after it, up to the next control with the WS_GROUP style. The first control in each group usually has the WS_TABSTOP style so that the user can move from group to group. The user can subsequently change the keyboard focus from one control in the group to the next control in the group by using the direction keys. You can turn this style on and off to change dialog box navigation. To change this style after a window has been created, use SetWindowLong. Private Const WS_HSCROLL = &H100000 ' Creates a window that has a horizontal scroll bar. Private Const WS_MAXIMIZE = &H1000000 ' Creates a window that is initially maximized. Private Const WS_MAXIMIZEBOX = &H10000 ' Creates a window that has a maximize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified. Private Const WS_MINIMIZE = &H20000000 ' Creates a window that is initially minimized. Same as the WS_ICONIC style. Private Const WS_MINIMIZEBOX = &H20000 ' Creates a window that has a minimize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified. Private Const WS_ICONIC = WS_MINIMIZE ' Creates a window that is initially minimized. Same as the WS_MINIMIZE style. Private Const WS_OVERLAPPED = &H0 ' Creates an overlapped window. An overlapped window has a title bar and a border. Same as the WS_TILED style. Private Const WS_POPUP = &H80000000 ' Creates a pop-up window. This style cannot be used with the WS_CHILD style. Private Const WS_SIZEBOX = &H40000 ' Creates a window that has a sizing border. Same as the WS_THICKFRAME style. Private Const WS_SYSMENU = &H80000 ' Creates a window that has a window menu on its title bar. The WS_CAPTION style must also be specified. Private Const WS_TABSTOP = &H10000 ' Specifies a control that can receive the keyboard focus when the user presses the TAB key. Pressing the TAB key changes the keyboard focus to the next control with the WS_TABSTOP style. You can turn this style on and off to change dialog box navigation. To change this style after a window has been created, use SetWindowLong. Private Const WS_THICKFRAME = &H40000 ' Creates a window that has a sizing border. Same as the WS_SIZEBOX style. Private Const WS_VISIBLE = &H10000000 ' Creates a window that is initially visible. This style can be turned on and off by using ShowWindow or SetWindowPos. Private Const WS_VSCROLL = &H200000 ' Creates a window that has a vertical scroll bar. Private Const WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX) ' Creates an overlapped window with the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles. Same as the WS_TILEDWINDOW style. Private Const WS_POPUPWINDOW = (WS_POPUP Or WS_BORDER Or WS_SYSMENU) ' Creates a pop-up window with WS_BORDER, WS_POPUP, and WS_SYSMENU styles. The WS_CAPTION and WS_POPUPWINDOW styles must be combined to make the window menu visible. Private Const WS_CHILDWINDOW = WS_CHILD ' Same as the WS_CHILD style. Private Const WS_TILED = WS_OVERLAPPED ' Creates an overlapped window. An overlapped window has a title bar and a border. Same as the WS_OVERLAPPED style. Private Const WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW ' Creates an overlapped window with the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles. Same as the WS_OVERLAPPEDWINDOW style. ' Error Constants Private Const MMSYSERR_NOERROR = 0 Private Const MCIERR_BASE = 256 Private Const MCIERR_BAD_CONSTANT = (MCIERR_BASE + 34) Private Const MCIERR_BAD_INTEGER = (MCIERR_BASE + 14) Private Const MCIERR_BAD_TIME_FORMAT = (MCIERR_BASE + 37) Private Const MCIERR_CANNOT_LOAD_DRIVER = (MCIERR_BASE + 10) Private Const MCIERR_CANNOT_USE_ALL = (MCIERR_BASE + 23) Private Const MCIERR_CREATEWINDOW = (MCIERR_BASE + 91) Private Const MCIERR_CUSTOM_DRIVER_BASE = (MCIERR_BASE + 256) Private Const MCIERR_DEVICE_LENGTH = (MCIERR_BASE + 54) Private Const MCIERR_DEVICE_LOCKED = (MCIERR_BASE + 32) Private Const MCIERR_DEVICE_NOT_INSTALLED = (MCIERR_BASE + 50) Private Const MCIERR_DEVICE_NOT_READY = (MCIERR_BASE + 20) Private Const MCIERR_DEVICE_OPEN = (MCIERR_BASE + 9) Private Const MCIERR_DEVICE_ORD_LENGTH = (MCIERR_BASE + 55) Private Const MCIERR_DEVICE_TYPE_REQUIRED = (MCIERR_BASE + 31) Private Const MCIERR_DRIVER = (MCIERR_BASE + 22) Private Const MCIERR_DRIVER_INTERNAL = (MCIERR_BASE + 16) Private Const MCIERR_DUPLICATE_ALIAS = (MCIERR_BASE + 33) Private Const MCIERR_DUPLICATE_FLAGS = (MCIERR_BASE + 39) Private Const MCIERR_EXTENSION_NOT_FOUND = (MCIERR_BASE + 25) Private Const MCIERR_EXTRA_CHARACTERS = (MCIERR_BASE + 49) Private Const MCIERR_FILE_NOT_FOUND = (MCIERR_BASE + 19) Private Const MCIERR_FILE_NOT_SAVED = (MCIERR_BASE + 30) Private Const MCIERR_FILE_READ = (MCIERR_BASE + 92) Private Const MCIERR_FILE_WRITE = (MCIERR_BASE + 93) Private Const MCIERR_FILENAME_REQUIRED = (MCIERR_BASE + 48) Private Const MCIERR_FLAGS_NOT_COMPATIBLE = (MCIERR_BASE + 28) Private Const MCIERR_GET_CD = (MCIERR_BASE + 51) Private Const MCIERR_HARDWARE = (MCIERR_BASE + 6) Private Const MCIERR_ILLEGAL_FOR_AUTO_OPEN = (MCIERR_BASE + 47) Private Const MCIERR_INTERNAL = (MCIERR_BASE + 21) Private Const MCIERR_INVALID_DEVICE_ID = (MCIERR_BASE + 1) Private Const MCIERR_INVALID_DEVICE_NAME = (MCIERR_BASE + 7) Private Const MCIERR_INVALID_FILE = (MCIERR_BASE + 40) Private Const MCIERR_MISSING_COMMAND_STRING = (MCIERR_BASE + 11) Private Const MCIERR_MISSING_DEVICE_NAME = (MCIERR_BASE + 36) Private Const MCIERR_MISSING_PARAMETER = (MCIERR_BASE + 17) Private Const MCIERR_MISSING_STRING_ARGUMENT = (MCIERR_BASE + 13) Private Const MCIERR_MULTIPLE = (MCIERR_BASE + 24) Private Const MCIERR_MUST_USE_SHAREABLE = (MCIERR_BASE + 35) Private Const MCIERR_NEW_REQUIRES_ALIAS = (MCIERR_BASE + 43) Private Const MCIERR_NO_CLOSING_QUOTE = (MCIERR_BASE + 38) Private Const MCIERR_NO_ELEMENT_ALLOWED = (MCIERR_BASE + 45) Private Const MCIERR_NO_INTEGER = (MCIERR_BASE + 56) Private Const MCIERR_NO_WINDOW = (MCIERR_BASE + 90) Private Const MCIERR_NONAPPLICABLE_FUNCTION = (MCIERR_BASE + 46) Private Const MCIERR_NOTIFY_ON_AUTO_OPEN = (MCIERR_BASE + 44) Private Const MCIERR_NULL_PARAMETER_BLOCK = (MCIERR_BASE + 41) Private Const MCIERR_OUT_OF_MEMORY = (MCIERR_BASE + 8) Private Const MCIERR_OUTOFRANGE = (MCIERR_BASE + 26) Private Const MCIERR_PARAM_OVERFLOW = (MCIERR_BASE + 12) Private Const MCIERR_PARSER_INTERNAL = (MCIERR_BASE + 15) Private Const MCIERR_SEQ_DIV_INCOMPATIBLE = (MCIERR_BASE + 80) Private Const MCIERR_SEQ_NOMIDIPRESENT = (MCIERR_BASE + 87) Private Const MCIERR_SEQ_PORT_INUSE = (MCIERR_BASE + 81) Private Const MCIERR_SEQ_PORT_MAPNODEVICE = (MCIERR_BASE + 83) Private Const MCIERR_SEQ_PORT_MISCERROR = (MCIERR_BASE + 84) Private Const MCIERR_SEQ_PORT_NONEXISTENT = (MCIERR_BASE + 82) Private Const MCIERR_SEQ_PORTUNSPECIFIED = (MCIERR_BASE + 86) Private Const MCIERR_SEQ_TIMER = (MCIERR_BASE + 85) Private Const MCIERR_SET_CD = (MCIERR_BASE + 52) Private Const MCIERR_SET_DRIVE = (MCIERR_BASE + 53) Private Const MCIERR_UNNAMED_RESOURCE = (MCIERR_BASE + 42) Private Const MCIERR_UNRECOGNIZED_COMMAND = (MCIERR_BASE + 5) Private Const MCIERR_UNRECOGNIZED_KEYWORD = (MCIERR_BASE + 3) Private Const MCIERR_UNSUPPORTED_FUNCTION = (MCIERR_BASE + 18) Private Const MCIERR_WAVE_INPUTSINUSE = (MCIERR_BASE + 66) Private Const MCIERR_WAVE_INPUTSUNSUITABLE = (MCIERR_BASE + 72) Private Const MCIERR_WAVE_INPUTUNSPECIFIED = (MCIERR_BASE + 69) Private Const MCIERR_WAVE_OUTPUTSINUSE = (MCIERR_BASE + 64) Private Const MCIERR_WAVE_OUTPUTSUNSUITABLE = (MCIERR_BASE + 70) Private Const MCIERR_WAVE_OUTPUTUNSPECIFIED = (MCIERR_BASE + 68) Private Const MCIERR_WAVE_SETINPUTINUSE = (MCIERR_BASE + 67) Private Const MCIERR_WAVE_SETINPUTUNSUITABLE = (MCIERR_BASE + 73) Private Const MCIERR_WAVE_SETOUTPUTINUSE = (MCIERR_BASE + 65) Private Const MCIERR_WAVE_SETOUTPUTUNSUITABLE = (MCIERR_BASE + 71) ' Volume Constants Private Const MIXER_GETLINEINFOF_COMPONENTTYPE = &H3 Private Const MIXER_GETLINECONTROLSF_ONEBYTYPE = &H2 Private Const MIXER_GETCONTROLDETAILSF_VALUE = &H0 Private Const MIXER_SETCONTROLDETAILSF_VALUE = &H0 Private Const MIXERCONTROL_CT_CLASS_FADER = &H50000000 Private Const MIXERCONTROL_CT_UNITS_UNSIGNED = &H30000 Private Const MIXERCONTROL_CONTROLTYPE_FADER = (MIXERCONTROL_CT_CLASS_FADER Or MIXERCONTROL_CT_UNITS_UNSIGNED) Private Const MIXERCONTROL_CONTROLTYPE_VOLUME = (MIXERCONTROL_CONTROLTYPE_FADER + 1) ' Drive Identification Constants Private Const DRIVE_CDROM = 5 Private Const DRIVE_FIXED = 3 Private Const DRIVE_RAMDISK = 6 Private Const DRIVE_REMOTE = 4 Private Const DRIVE_REMOVABLE = 2 Private Const DRIVE_UNKNOWN = 0 ' Constants - SendMessage Private Const WM_SETICON = &H80 Private Const ICON_BIG = 1 ' Private Variable Declarations Private bUserCanceled As Boolean ' Volume Related Variables Private VolCtrl_Sys As MIXERCONTROL Private VolCtrl_Wav As MIXERCONTROL Private VolCtrl_Mid As MIXERCONTROL Private VolCtrl_CD As MIXERCONTROL Private VolMin_Sys As Long Private VolMax_Sys As Long Private VolMin_Wav As Long Private VolMax_Wav As Long Private VolMin_Mid As Long Private VolMax_Mid As Long Private VolMin_CD As Long Private VolMax_CD As Long Private hMixer As Long ' Win32 API Function Declarations Private Declare Sub CopyPtrFromStruct Lib "kernel32.dll" Alias "RtlMoveMemory" (ByVal ptr As Long, struct As Any, ByVal cb As Long) Private Declare Sub CopyStructFromPtr Lib "kernel32.dll" Alias "RtlMoveMemory" (struct As Any, ByVal ptr As Long, ByVal cb As Long) Private Declare Function auxGetVolume Lib "winmm.dll" (ByVal uDeviceID As Long, ByRef lpdwVolume As Long) As Long Private Declare Function auxSetVolume Lib "winmm.dll" (ByVal uDeviceID As Long, ByVal dwVolume As Long) As Long Private Declare Function GetDriveTypeA Lib "kernel32.dll" (ByVal nDrive As String) As Long Private Declare Function GetShortPathName Lib "kernel32.dll" Alias "GetShortPathNameA" (ByVal strLongPath As String, ByVal strReturnBuffer As String, ByVal ReturnBufferLen As Long) As Long Private Declare Function GlobalAlloc Lib "kernel32.dll" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long Private Declare Function GlobalLock Lib "kernel32.dll" (ByVal hMem As Long) As Long Private Declare Function GlobalFree Lib "kernel32.dll" (ByVal hMem As Long) As Long Private Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal ErrorNumber As Long, ByVal ReturnBuffer As String, ByVal ReturnBufferSize As Long) As Long 'BOOL Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal CommandString As String, ByVal ReturnBuffer As String, ByVal ReturnBufferSize As Long, ByVal hCallback As Long) As Long 'MCIERROR Private Declare Function mixerClose Lib "winmm.dll" (ByVal hMixer As Long) As Long Private Declare Function mixerGetControlDetails Lib "winmm.dll" Alias "mixerGetControlDetailsA" (ByVal hMixerObj As Long, ByRef pMixerCD As MIXERCONTROLDETAILS, ByVal fdwDetails As Long) As Long Private Declare Function mixerGetLineControls Lib "winmm.dll" Alias "mixerGetLineControlsA" (ByVal hMixerObj As Long, pMixerLc As MIXERLINECONTROLS, ByVal fdwControls As Long) As Long Private Declare Function mixerGetLineInfo Lib "winmm.dll" Alias "mixerGetLineInfoA" (ByVal hMixerObj As Long, pMixerL As MIXERLINE, ByVal fdwInfo As Long) As Long Private Declare Function mixerOpen Lib "winmm.dll" (ByRef phMixer As Long, ByVal uMxId As Long, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal fdwOpen As Long) As Long Private Declare Function mixerSetControlDetails Lib "winmm.dll" (ByVal hMixerObj As Long, ByRef pMixerCD As MIXERCONTROLDETAILS, ByVal fdwDetails As Long) As Long Private Declare Function SetWindowText Lib "USER32" (ByVal hWnd As Long, ByVal LPString As String) Private Declare Function SendMessage Lib "USER32.DLL" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Private Sub Class_Initialize() On Error Resume Next MCI_CloseAll ' Open the volume mixer with deviceID 0 If mixerOpen(hMixer, 0, 0, 0, 0) <> MMSYSERR_NOERROR Then MsgBox "An error occured while trying to access the volume mixer.", vbOKOnly + vbExclamation, " Error Opening Volume Mixer" Else ' Get SYSTEM VOLUME information If GetVolumeObject(hMixer, MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, VolCtrl_Sys) = True Then VolMax_Sys = VolCtrl_Sys.lMaximum VolMin_Sys = VolCtrl_Sys.lMinimum End If ' Get WAVE VOLUME information If GetVolumeObject(hMixer, MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT, VolCtrl_Wav) = True Then VolMax_Wav = VolCtrl_Wav.lMaximum VolMin_Wav = VolCtrl_Wav.lMinimum End If ' Get MIDI VOLUME information If GetVolumeObject(hMixer, MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER, VolCtrl_Mid) = True Then VolMax_Mid = VolCtrl_Mid.lMaximum VolMin_Mid = VolCtrl_Mid.lMinimum End If ' Get CD-ROM VOLUME information If GetVolumeObject(hMixer, MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC, VolCtrl_CD) = True Then VolMax_CD = VolCtrl_CD.lMaximum VolMin_CD = VolCtrl_CD.lMinimum End If End If End Sub Private Sub Class_Terminate() On Error Resume Next MCI_CloseAll mixerClose hMixer End Sub 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX '============================================================================================================= ' MCI_Close ' ' Purpose : ' Closes the specified device, and frees up any memory associated with that device. ' ' Param Use ' ------------------------------------ ' DeviceAlias Specifies the name of the device to perform the action on. ' hCallbackProc Optional. Specifies the handle of the window to recieve a MM_MCINOTIFY message when ' the device completes an action. In order for this to work, you must specify the ' handle to the window in your initial call to MCI_Open, then specify the handle of ' that window in subsequent calls to methods like this. ' WaitToComplete Optional. If this is set to TRUE, this function will not return control to the application ' until the MCI call has completed. ' ShowErrors Optional. If this is set to TRUE and an error occurs, the user will be shown a message describing ' the error that occured. ' ' Return ' ------ ' FALSE if error occurs ' TRUE if succeeds ' '============================================================================================================= Public Function MCI_Close(ByVal DeviceAlias As String, Optional ByVal hCallbackProc As Long, Optional ByVal WaitToComplete As Boolean = True, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Make sure parameters are valid DeviceAlias = Trim(DeviceAlias) If DeviceAlias = "" Then Exit Function ' Close the device MCI_Close = MCIa_SendCommand("close " & DeviceAlias, , , hCallbackProc, WaitToComplete, ShowErrors) End Function '============================================================================================================= ' MCI_CloseAll ' ' Purpose : ' Closes all devices opened by the current program, and frees up any memory associated with those device. ' ' Param Use ' ------------------------------------ ' hCallbackProc Optional. Specifies the handle of the window to recieve a MM_MCINOTIFY message when ' the device completes an action. In order for this to work, you must specify the ' handle to the window in your initial call to MCI_Open, then specify the handle of ' that window in subsequent calls to methods like this. ' WaitToComplete Optional. If this is set to TRUE, this function will not return control to the application ' until the MCI call has completed. ' ShowErrors Optional. If this is set to TRUE and an error occurs, the user will be shown a message describing ' the error that occured. ' ' Return ' ------ ' FALSE if error occurs ' TRUE if succeeds ' '============================================================================================================= Public Function MCI_CloseAll(Optional ByVal hCallbackProc As Long, Optional ByVal WaitToComplete As Boolean = True, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Close all devices opened by this program MCI_CloseAll = MCIa_SendCommand("close all", , , hCallbackProc, WaitToComplete, ShowErrors) End Function '============================================================================================================= ' MCI_Door ' ' Purpose : ' Either opens or closes the door to the specified device. This is most commonly used for CD-ROM drives, but ' can be used for other device types as well. ' ' Param Use ' ------------------------------------ ' DeviceAlias Specifies the name of the device to perform the action on. ' OpenDoor If set to true, opens the door. If set to FALSE, closes the door. ' hCallbackProc Optional. Specifies the handle of the window to recieve a MM_MCINOTIFY message when ' the device completes an action. In order for this to work, you must specify the ' handle to the window in your initial call to MCI_Open, then specify the handle of ' that window in subsequent calls to methods like this. ' WaitToComplete Optional. If this is set to TRUE, this function will not return control to the application ' until the MCI call has completed. ' ShowErrors Optional. If this is set to TRUE and an error occurs, the user will be shown a message describing ' the error that occured. ' ' Return ' ------ ' FALSE if error occurs ' TRUE if succeeds ' '============================================================================================================= Public Function MCI_Door(ByVal DeviceAlias As String, ByVal OpenDoor As Boolean, Optional ByVal hCallbackProc As Long, Optional ByVal WaitToComplete As Boolean = True, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Make sure parameters are valid DeviceAlias = Trim(DeviceAlias) If DeviceAlias = "" Then Exit Function ' Open or close the door to the device If OpenDoor = True Then MCI_Door = MCIa_SendCommand("Set " & DeviceAlias & " door open", , , hCallbackProc, WaitToComplete, ShowErrors) Else MCI_Door = MCIa_SendCommand("Set " & DeviceAlias & " door closed", , , hCallbackProc, WaitToComplete, ShowErrors) End If End Function '============================================================================================================= ' MCI_Open ' ' Purpose : ' Opens the specified device and assigns it the name, or alias, that you give it. After calling OPEN, you ' can then make other calls to it. ' ' *NOTE - If you specify "MPEGVideo" as the DeviceType parameter, it will most likely play all common media ' types. In fact, it plays AVI files better than the "AVIVideo" device type most of the time. ' However, this option is not available if ActiveMove/DirectShow are not installed. ' ' *NOTE - The "Shareable" option is not very widely supported. If you get an error about an option not being ' supported, try taking off that option. ' ' *NOTE - This function makes the application wait for the device to open because it must be open to make ' further calls to it successfully ' ' Param Use ' ------------------------------------ ' DeviceAlias Specifies the name of the device to perform the action on. ' DeviceType Optional. Specifies the type of device to open. The default is "other". If left ' at "other", chances are the device will work just fine because "other" opens just about ' any device type. ' FilePath Optional. Specifies the path to the file to open. This is optional because it is ' possible to open devices without specifying a source for the device... such as when you ' open a new device to write out to. ' Shareable Optional. If this is set to TRUE, other devices aliases will be able to access the ' same device at the same time. This option is NOT very widely supported among multimedia ' device drivers so it is recommended that you do not use it. ' BufferSize Optional. Sets the size, in seconds, of the buffer used by the waveform-audio device. ' The default size of the buffer is set when the waveform-audio device is installed or ' configured. Typically the buffer size is set to 4 seconds. With the MCIWAVE device, the ' minimum size is 2 seconds and the maximum size is 9 seconds. ' Parent_Handle Optional. Specifies the window handle of the parent window. This applies to AVIVideo, ' MPEGVideo, MPEGVideo2, and Overlay device types only. ' Style_Child Optional. If set to true, the AVIVideo, MPEGVideo, MPEGVideo2, or Overlay video being ' played will play within the parent specified in the "Parent_Handle" parameter. So if ' you set the "Parent_Handle" to the handle of a PictureBox control and set this parameter ' to TRUE, the video will be displayed within that PictureBox control instead of in a ' new popup window. ' Style_Overlapped Optional. If set to TRUE, opens a window with an overlapped window style. This only ' applies to AVIVideo, MPEGVideo, MPEGVideo2, or Overlay device types. ' Style_Popup Optional. If set to TRUE, opens a window with a pop-up window style. This only ' applies to AVIVideo, MPEGVideo, MPEGVideo2, or Overlay device types. ' Style_Type Optional. Is not really necissary but allows you to specify additional window styles ' via the WS_* constant values (i.e. - WS_BORDER, etc) ' hCallbackProc Optional. Specifies the handle of the window to recieve a MM_MCINOTIFY message when ' the device completes an action. In order for this to work, you must specify the ' handle to the window in your initial call to MCI_Open, then specify the handle of ' that window in subsequent calls to methods like this. ' ShowErrors Optional. If this is set to TRUE and an error occurs, the user will be shown a message describing ' the error that occured. ' ' Return ' ------ ' FALSE if error occurs ' TRUE if succeeds ' '------------------------------------------------------------------------------------------------------------- ' ' The following table lists the flags that can be specified in the lpszOpenFlags parameter and their meanings: ' ' Open statement options: Meaning: ' ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ' type Specifies the device type of a file. ' alias Specifies an alternate name for the given device. ' If specified, it must be used as the device_id in subsequent commands. ' shareable Initializes the device or file as shareable. Subsequent attempts to open the ' device or file fail unless you specify "shareable" in both the original and ' subsequent open commands. MCI returns an invalid device error if the device ' is already open and not shareable. The MCISEQ sequencer and MCIWAVE devices ' do not support shared files. ' Specifies the name of the device element (file) loaded when the device opens. ' buffer Sets the size, in seconds, of the buffer used by the waveform-audio device. ' The default size of the buffer is set when the waveform-audio device is ' installed or configured. Typically the buffer size is set to 4 seconds. ' With the MCIWAVE device, the minimum size is 2 seconds and the maximum size ' is 9 seconds. ' parent Specifies the window handle of the parent window. ' style child Opens a window with a child window style. ' style overlapped Opens a window with an overlapped window style. ' style popup Opens a window with a pop-up window style. ' style Indicates a window style. ' '============================================================================================================= Public Function MCI_Open(ByVal DeviceAlias As String, Optional ByVal DeviceType As MciDeviceTypes = other, Optional ByVal FilePath As String, Optional ByVal Shareable As Boolean = False, Optional ByVal BufferSize As Integer, Optional ByVal Parent_Handle As Long, Optional ByVal Style_Child As Boolean, Optional ByVal Style_Overlapped As Boolean, Optional ByVal Style_Popup As Boolean, Optional ByVal Style_Type As String, Optional ByVal hCallbackProc As Long, Optional ByVal ShowErrors As Boolean = False) As Boolean Dim OpenString As String Dim DeviceName As String ' Make sure parameters are valid Style_Type = Trim(Style_Type) DeviceAlias = Trim(DeviceAlias) If DeviceAlias = "" Then Exit Function FilePath = Trim(FilePath) FilePath = Get16bitFilePath(FilePath) 'Path must be in 16bit form (no spaces allowed) ' Specify the name of the device Select Case DeviceType Case CDAudio: DeviceName = "cdaudio" Case AVIVideo: DeviceName = "avivideo" Case Sequencer: DeviceName = "Sequencer" Case WaveAudio: DeviceName = "WaveAudio" Case MPEGVideo: DeviceName = "mpegvideo" Case MPEGVideo2: DeviceName = "mpegvideo2" Case VCR: DeviceName = "vcr" Case VideoDisc: DeviceName = "videodisc" Case Overlay: DeviceName = "overlay" Case other: DeviceName = "other" Case Else: DeviceName = "other" End Select ' Create the open string based on the options specified Select Case DeviceType ' Options specific to CD Audio Case CDAudio If FilePath = "" Then OpenString = "open " & DeviceName & " alias " & DeviceAlias & " wait" Else FilePath = LCase(Left(FilePath, 1)) ' Get the CD-ROM drive letter to use If Asc(FilePath) >= 97 And Asc(FilePath) <= 122 Then OpenString = "open " & FilePath & ": type " & DeviceName & " alias " & DeviceAlias & " wait" Else OpenString = "open " & DeviceName & " alias " & DeviceAlias & " wait" End If End If If Shareable = True Then OpenString = OpenString & " shareable" ' Options that pertain to WaveAudio, Sequencer, VCR, and VideoDisc (non-video / basic options) Case WaveAudio, Sequencer, VCR, VideoDisc If FilePath <> "" And Dir(FilePath) <> "" Then OpenString = "open " & DeviceName & "!" & FilePath & " alias " & DeviceAlias & " wait" Else OpenString = "open " & DeviceName & " alias " & DeviceAlias & " wait" End If If DeviceType = WaveAudio Then If BufferSize > 0 Then OpenString = OpenString & " buffer " & CStr(BufferSize) End If If Shareable = True Then OpenString = OpenString & " shareable" ' Options that pertain to AVIVideo, MPEGVideo, MPEGVideo2, and Overlay (video options) Case AVIVideo, MPEGVideo, MPEGVideo2, Overlay If FilePath <> "" And Dir(FilePath) <> "" Then OpenString = "open " & DeviceName & "!" & FilePath & " alias " & DeviceAlias & " wait" Else OpenString = "open " & DeviceName & " alias " & DeviceAlias & " wait" End If If Parent_Handle <> 0 Then OpenString = OpenString & " parent " & CStr(Parent_Handle) If Shareable = True Then OpenString = OpenString & " shareable" If Style_Child = True Then OpenString = OpenString & " style child" If Style_Overlapped = True Then OpenString = OpenString & " style overlapped" If Style_Popup = True Then OpenString = OpenString & " style popup" If Style_Type <> "" Then OpenString = OpenString & " style " & Style_Type ' Device = NOT SPECIFIED (selected by the file extention) * NOTE - Not all parameters apply to each file type... see documentation for the "MciDeviceTypes" enumeration for more info Case Else If FilePath <> "" And Dir(FilePath) <> "" Then OpenString = "open " & FilePath & " alias " & DeviceAlias & " wait" Else Exit Function End If If Parent_Handle <> 0 Then OpenString = OpenString & " parent " & CStr(Parent_Handle) If Shareable = True Then OpenString = OpenString & " shareable" If Style_Child = True Then OpenString = OpenString & " style child" If Style_Overlapped = True Then OpenString = OpenString & " style overlapped" If Style_Popup = True Then OpenString = OpenString & " style popup" If Style_Type <> "" Then OpenString = OpenString & " style " & Style_Type End Select ' Open the device according to the parameters set MCI_Open = MCIa_SendCommand(OpenString, , , hCallbackProc, False, ShowErrors) End Function '============================================================================================================= ' MCI_Pause ' ' Purpose : ' Pauses the playback of the specified Device. ' ' Param Use ' ------------------------------------ ' DeviceAlias Specifies the name of the device to perform the action on. ' hCallbackProc Optional. Specifies the handle of the window to recieve a MM_MCINOTIFY message when ' the device completes an action. In order for this to work, you must specify the ' handle to the window in your initial call to MCI_Open, then specify the handle of ' that window in subsequent calls to methods like this. ' WaitToComplete Optional. If this is set to TRUE, this function will not return control to the application ' until the MCI call has completed. ' ShowErrors Optional. If this is set to TRUE and an error occurs, the user will be shown a message describing ' the error that occured. ' ' Return ' ------ ' FALSE if error occurs ' TRUE if succeeds ' '============================================================================================================= Public Function MCI_Pause(ByVal DeviceAlias As String, Optional ByVal hCallbackProc As Long, Optional ByVal WaitToComplete As Boolean = False, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Make sure parameters are valid DeviceAlias = Trim(DeviceAlias) If DeviceAlias = "" Then Exit Function ' Pause the device MCI_Pause = MCIa_SendCommand("pause " & DeviceAlias, , , hCallbackProc, WaitToComplete, ShowErrors) End Function '============================================================================================================= ' MCI_Play ' ' Purpose : ' Starts the playback of the specified Device. ' ' *NOTE - The "PlayFullScreen" parameter is only supported by AVIVideo and MPEGVideo ' ' Param Use ' ------------------------------------ ' DeviceAlias Specifies the name of the device to perform the action on. ' SpecifyStartPosition Optional. If set to TRUE, allows you to specify at what position to start the playback. ' StartPosition Optional. If the "SpecifyStartPosition" parameter is set to TRUE, this parameter ' specifies at what position to start playback at. ' SpecifyEndPosition Optional. If set to TRUE, allows you to specify at what position to STOP the playback. ' EndPosition Optional. If the "SpecifyEndPosition" parameter is set to TRUE, this parameter ' specifies at what position to stop playback at. ' PlayFullScreen Optional. When playing video, you can set this parameter to play the video full screen. ' Use this only when playing compressed files, uncompressed files won't play full-screen. ' RepeatPlay Optional. If this parameter is set to TRUE, the device will continue to play in a loop ' over and over again instead of stoping at th end of the media. ' hCallbackProc Optional. Specifies the handle of the window to recieve a MM_MCINOTIFY message when ' the device completes an action. In order for this to work, you must specify the ' handle to the window in your initial call to MCI_Open, then specify the handle of ' that window in subsequent calls to methods like this. ' WaitToComplete Optional. If this is set to TRUE, this function will not return control to the application ' until the MCI call has completed. ' ShowErrors Optional. If this is set to TRUE and an error occurs, the user will be shown a message describing ' the error that occured. ' ' Return ' ------ ' FALSE if error occurs ' TRUE if succeeds ' '============================================================================================================= Public Function MCI_Play(ByVal DeviceAlias As String, Optional ByVal SpecifyStartPosition As Boolean, Optional ByVal StartPosition As Long, Optional ByVal SpecifyEndPosition As Boolean, Optional ByVal EndPosition As Long, Optional ByVal PlayFullScreen As Boolean, Optional ByVal RepeatPlay As Boolean, Optional ByVal hCallbackProc As Long, Optional ByVal WaitToComplete As Boolean = False, Optional ByVal ShowErrors As Boolean = False) As Boolean Dim PlayString As String ' Make sure parameters are valid DeviceAlias = Trim(DeviceAlias) If DeviceAlias = "" Then Exit Function ' Assemble the string to be used to play the device PlayString = "play " & DeviceAlias If SpecifyStartPosition = True Then PlayString = PlayString & " from " & CStr(StartPosition) If SpecifyEndPosition = True Then PlayString = PlayString & " to " & CStr(StartPosition) If RepeatPlay = True Then PlayString = PlayString & " repeat" If PlayFullScreen = True Then PlayString = PlayString & " fullscreen" 'This only works for AVI files ' Play the device MCI_Play = MCIa_SendCommand(PlayString, , , hCallbackProc, WaitToComplete, ShowErrors) End Function '============================================================================================================= ' MCI_Resume ' ' Purpose : ' Resumes the play of paused devices. ' ' Param Use ' ------------------------------------ ' DeviceAlias Specifies the name of the device to perform the action on. ' hCallbackProc Optional. Specifies the handle of the window to recieve a MM_MCINOTIFY message when ' the device completes an action. In order for this to work, you must specify the ' handle to the window in your initial call to MCI_Open, then specify the handle of ' that window in subsequent calls to methods like this. ' WaitToComplete Optional. If this is set to TRUE, this function will not return control to the application ' until the MCI call has completed. ' ShowErrors Optional. If this is set to TRUE and an error occurs, the user will be shown a message describing ' the error that occured. ' ' Return ' ------ ' FALSE if error occurs ' TRUE if succeeds ' '============================================================================================================= Public Function MCI_Resume(ByVal DeviceAlias As String, Optional ByVal hCallbackProc As Long, Optional ByVal WaitToComplete As Boolean = False, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Make sure parameters are valid DeviceAlias = Trim(DeviceAlias) If DeviceAlias = "" Then Exit Function ' Resume the device MCI_Resume = MCIa_SendCommand("resume " & DeviceAlias, , , hCallbackProc, WaitToComplete, ShowErrors) End Function '============================================================================================================= ' MCI_Seek ' ' Purpose : ' Skips the current position of the playback ahead (or back) to the specified seek position. ' ' Param Use ' ------------------------------------ ' DeviceAlias Specifies the name of the device to perform the action on. ' SeekPosistion Specifies the seek position to skip to. ' hCallbackProc Optional. Specifies the handle of the window to recieve a MM_MCINOTIFY message when ' the device completes an action. In order for this to work, you must specify the ' handle to the window in your initial call to MCI_Open, then specify the handle of ' that window in subsequent calls to methods like this. ' WaitToComplete Optional. If this is set to TRUE, this function will not return control to the application ' until the MCI call has completed. ' ShowErrors Optional. If this is set to TRUE and an error occurs, the user will be shown a message describing ' the error that occured. ' ' Return ' ------ ' FALSE if error occurs ' TRUE if succeeds ' '============================================================================================================= Public Function MCI_Seek(ByVal DeviceAlias As String, ByVal SeekPosistion As Long, Optional ByVal hCallbackProc As Long, Optional ByVal WaitToComplete As Boolean = True, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Make sure parameters are valid DeviceAlias = Trim(DeviceAlias) If DeviceAlias = "" Then Exit Function ' Seek to the specified position of the file MCI_Seek = MCIa_SendCommand("seek " & DeviceAlias & " to " & CStr(SeekPosistion), , , hCallbackProc, WaitToComplete, ShowErrors) End Function '============================================================================================================= ' MCI_SeekBeginning ' ' Purpose : ' Moves the current play position to the beginning of the media. ' ' Param Use ' ------------------------------------ ' DeviceAlias Specifies the name of the device to perform the action on. ' hCallbackProc Optional. Specifies the handle of the window to recieve a MM_MCINOTIFY message when ' the device completes an action. In order for this to work, you must specify the ' handle to the window in your initial call to MCI_Open, then specify the handle of ' that window in subsequent calls to methods like this. ' WaitToComplete Optional. If this is set to TRUE, this function will not return control to the application ' until the MCI call has completed. ' ShowErrors Optional. If this is set to TRUE and an error occurs, the user will be shown a message describing ' the error that occured. ' ' Return ' ------ ' FALSE if error occurs ' TRUE if succeeds ' '============================================================================================================= Public Function MCI_SeekBeginning(ByVal DeviceAlias As String, Optional ByVal hCallbackProc As Long, Optional ByVal WaitToComplete As Boolean = True, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Make sure parameters are valid DeviceAlias = Trim(DeviceAlias) If DeviceAlias = "" Then Exit Function ' Seek to the beginning of the file MCI_SeekBeginning = MCIa_SendCommand("seek " & DeviceAlias & " to start", , , hCallbackProc, WaitToComplete, ShowErrors) End Function '============================================================================================================= ' MCI_SeekEnd ' ' Purpose : ' Moves the current play position to the end of the media. ' ' Param Use ' ------------------------------------ ' DeviceAlias Specifies the name of the device to perform the action on. ' hCallbackProc Optional. Specifies the handle of the window to recieve a MM_MCINOTIFY message when ' the device completes an action. In order for this to work, you must specify the ' handle to the window in your initial call to MCI_Open, then specify the handle of ' that window in subsequent calls to methods like this. ' WaitToComplete Optional. If this is set to TRUE, this function will not return control to the application ' until the MCI call has completed. ' ShowErrors Optional. If this is set to TRUE and an error occurs, the user will be shown a message describing ' the error that occured. ' ' Return ' ------ ' FALSE if error occurs ' TRUE if succeeds ' '============================================================================================================= Public Function MCI_SeekEnd(ByVal DeviceAlias As String, Optional ByVal hCallbackProc As Long, Optional ByVal WaitToComplete As Boolean = True, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Make sure parameters are valid DeviceAlias = Trim(DeviceAlias) If DeviceAlias = "" Then Exit Function ' Seek to the end of the file MCI_SeekEnd = MCIa_SendCommand("seek " & DeviceAlias & " to end", , , hCallbackProc, WaitToComplete, ShowErrors) End Function '============================================================================================================= ' MCI_Set ' ' Purpose : ' Alters the specified device or device playback by sending the specified command to it. The commands vary ' between device types and not all commands are compatible with all device types. See table below for details. ' ' *NOTE - This function makes the application wait for the device parameter to be set because it must finish ' being set before further calls to it can be made successfully ' ' Param Use ' ------------------------------------ ' DeviceAlias Specifies the name of the device to perform the action on. ' ControlSettingString Specifies the string to pass to set the device condition or information. This can be ' any of the applicable commands below and can do a wide variety of things to the device. ' hCallbackProc Optional. Specifies the handle of the window to recieve a MM_MCINOTIFY message when ' the device completes an action. In order for this to work, you must specify the ' handle to the window in your initial call to MCI_Open, then specify the handle of ' that window in subsequent calls to methods like this. ' ShowErrors Optional. If this is set to TRUE and an error occurs, the user will be shown a message describing ' the error that occured. ' ' Return ' ------ ' FALSE if error occurs ' TRUE if succeeds ' '------------------------------------------------------------------------------------------------------------- ' ' Recognized device setting strings: '============================================================================================================= 'ControlSettingString: Applies To: Meaning: '¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 'alignment WaveAudio Sets the alignment of data blocks relative to the start of data passed to the waveform-audio device. The file is saved in this format. 'any input WaveAudio Use any input that supports the current format when recording. This is the default setting. 'any output WaveAudio Use any output that supports the current format when playing. This is the default. 'assemble record on/off VCR In assemble mode, all tracks are recorded as defined by the device. Most VCRs are in assemble mode by default. 'audio all on/off AVIVideo, Disables or enables audio output. Video-overlay devices, the MCISEQ sequencer, and the MCIWAVE waveform-audio device do not support this flag. ' CDAudio, ' Overlay, ' Sequencer, ' VCR, ' VideoDisc, ' WaveAudio 'audio left on/off AVIVideo, Disables or enables output to either the left or the right audio channel. Video-overlay devices, the MCISEQ sequencer, and the MCIWAVE waveform-audio device do not support this flag. ' CDAudio, ' Overlay, ' Sequencer, ' VCR, ' VideoDisc, ' WaveAudio 'audio right on/off AVIVideo, Disables or enables output to either the left or the right audio channel. Video-overlay devices, the MCISEQ sequencer, and the MCIWAVE waveform-audio device do not support this flag. ' CDAudio, ' Overlay, ' Sequencer, ' VCR, ' VideoDisc, ' WaveAudio 'bitspersample WaveAudio Sets the number of bits per PCM (Pulse Code Modulation) sample played or recorded. The file is saved in this format. 'bytespersec WaveAudio Sets the average number of bytes per second played or recorded. The file is saved in this format. 'channels WaveAudio Sets the channels for playing and recording. The file is saved in this format. 'clock