Attribute VB_Name = "modMemoryAVI" Option Explicit '============================================================================================================= ' ' modMemoryAVI Module ' ------------------- ' ' Created By : Kevin Wilson ' http://www.TheVBZone.com ( The VB Zone ) ' http://www.TheVBZone.net ( The VB Zone .net ) ' ' Last Update : January 4, 2002 ' ' VB Versions : 5.0 / 6.0 ' ' Requires : Sound Card ' (This module was designed to be used with the "cResource.cls" class module, but does not require it) ' ' Description : This module allows you to play, pause, stop, and manipulate any AVI file from memory that you ' have previously put into a compiled resource DLL (ActiveX DLL or standard C DLL). This saves ' you the hastle and delay of having to load the file from a resource, save it to disk, then ' load it from disk and play it. This module uses existing drivers to play the AVI files, so ' there's no need for dependencies, etc. ' ' Example Use: ' ' Option Explicit ' Private hLib As Long ' Private Sub Form_Click() ' ' Restart the AVI ' ResAVI_SeekBeginning ' ResAVI_Play True, 0, , , , , , True ' End Sub ' Private Sub Form_DblClick() ' ' Close the AVI and free the resource DLL ' ResAVI_CloseAll , True ' FreeLibrary hLib ' End Sub ' Private Sub Form_Load() ' Dim strPath As String ' Dim strReturn As String ' Dim strStyles As String ' ' Show the window so we can see the AVI being played on it ' Me.Visible = True ' DoEvents ' ' Loads the resource DLL ' strPath = App.Path ' If Right(strPath, 1) <> "\" Then strPath = strPath & "\" ' strPath = strPath & "Resource.dll" & Chr(0) ' hLib = LoadLibrary(strPath) ' ' Open and play the AVI file from the DLL ' strStyles = CStr(WS_BORDER Or WS_CAPTION Or WS_SYSMENU Or _ ' WS_MAXIMIZEBOX Or WS_MINIMIZEBOX Or WS_HSCROLL Or _ ' WS_VSCROLL Or WS_VISIBLE Or WS_THICKFRAME) ' ResAVI_Open hLib, 101, "AVI", , Me.hWnd, , , , strStyles, True ' ResAVI_SeekBeginning ' ResAVI_Play True, 0, , , , True, , True ' End Sub ' Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) ' Form_DblClick ' End Sub ' '_____________________________________________________________________________________________________________ ' 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. ' '============================================================================================================= ' Type - MMIOProc.lpMMIOInfo Public Type MMIOINFO dwFlags As Long 'DWORD // Flags specifying how a file was opened fccIOProc As Long 'FOURCC // Four-character code identifying the file's I/O procedure. If the I/O procedure is not an installed I/O procedure, this member is NULL. pIOProc As Long 'LPMMIOPROC // Address of file's IO procedure. wErrorRet As Long 'UINT // Extended error value from the mmioOpen function if it returns NULL. This member is not used to return extended error information from any other functions. hTask As Long 'HTASK // Handle of a local I/O procedure. Media Control Interface (MCI) devices that perform file I/O in the background and need an I/O procedure can locate a local I/O procedure with this handle. cchBuffer As Long 'LONG // Size, in bytes, of the file's I/O buffer. If the file does not have an I/O buffer, this member is zero. pchBuffer As String 'HPSTR // Address of the file's I/O buffer. If the file is unbuffered, this member is NULL. pchNext As String 'HPSTR // Address of the next location in the I/O buffer to be read or written. If no more bytes can be read without calling the mmioAdvance or mmioRead function, this member points to the pchEndRead member. If no more bytes can be written without calling the mmioAdvance or mmioWrite function, this member points to the pchEndWrite member. pchEndRead As String 'HPSTR // Address of the location that is 1 byte past the last location in the buffer that can be read. pchEndWrite As String 'HPSTR // Address of the location that is 1 byte past the last location in the buffer that can be written. lBufOffset As Long 'LONG // Reserved. lDiskOffset As Long 'LONG // Current file position, which is an offset, in bytes, from the beginning of the file. I/O procedures are responsible for maintaining this member. adwInfo(3) As Long 'DWORD // State information maintained by the I/O procedure. I/O procedures can also use these members to transfer information from the application to the I/O procedure when the application opens a file. dwReserved1 As Long 'DWORD // Reserved. dwReserved2 As Long 'DWORD // Reserved. hmmio As Long 'HMMIO // Handle of the open file, as returned by the mmioOpen function. I/O procedures can use this handle when calling other multimedia file I/O functions. End Type ' Constants - Window Sytles (Used in the mciSendString "open" command for the "Style_Type" parameter) Public Const WS_BORDER = &H800000 ' Creates a window that has a thin-line border. Public Const WS_CAPTION = &HC00000 ' Creates a window that has a title bar (includes the WS_BORDER style). Public 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. Public 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. Public 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. Public 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. Public 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. Public 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. Public Const WS_HSCROLL = &H100000 ' Creates a window that has a horizontal scroll bar. Public Const WS_MAXIMIZE = &H1000000 ' Creates a window that is initially maximized. Public 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. Public Const WS_MINIMIZE = &H20000000 ' Creates a window that is initially minimized. Same as the WS_ICONIC style. Public 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. Public Const WS_ICONIC = WS_MINIMIZE ' Creates a window that is initially minimized. Same as the WS_MINIMIZE style. Public Const WS_OVERLAPPED = &H0 ' Creates an overlapped window. An overlapped window has a title bar and a border. Same as the WS_TILED style. Public Const WS_POPUP = &H80000000 ' Creates a pop-up window. This style cannot be used with the WS_CHILD style. Public Const WS_SIZEBOX = &H40000 ' Creates a window that has a sizing border. Same as the WS_THICKFRAME style. Public Const WS_SYSMENU = &H80000 ' Creates a window that has a window menu on its title bar. The WS_CAPTION style must also be specified. Public 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. Public Const WS_THICKFRAME = &H40000 ' Creates a window that has a sizing border. Same as the WS_SIZEBOX style. Public Const WS_VISIBLE = &H10000000 ' Creates a window that is initially visible. This style can be turned on and off by using ShowWindow or SetWindowPos. Public Const WS_VSCROLL = &H200000 ' Creates a window that has a vertical scroll bar. Public 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. Public 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. Public Const WS_CHILDWINDOW = WS_CHILD ' Same as the WS_CHILD style. Public 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. Public 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. ' Constants - MMIOProc.uMessage Private Const MMIOM_READ = 0 ' Read (lParam1 = Address of the buffer to be filled with data read, lParam2 = Number of bytes to read) Private Const MMIOM_WRITE = 1 ' Write (lParam1 = Address of a buffer containing the data to write, lParam2 = Number of bytes to write) Private Const MMIOM_SEEK = 2 ' Seek to a new position in file (lParam1 = New file position, ' lParam2 = ' SEEK_CUR - Move the file position to be lNewFilePos bytes from the current position. NewFilePos can be positive or negative. ' SEEK_END - Move the file position to be lNewFilePos bytes from the end of the file. ' SEEK_SET - Move the file position to be lNewFilePos bytes from the beginning of the file. Private Const MMIOM_OPEN = 3 ' Open file (lParam1 = File Name) Private Const MMIOM_CLOSE = 4 ' Close file (lParam1 = Close Flags) Private Const MMIOM_WRITEFLUSH = 5 ' write and flush ' Constants - MMIOProc.lParam2 Private Const SEEK_SET = 0 Private Const SEEK_CUR = 1 Private Const SEEK_END = 2 ' Constants - mmioInstallIOProc.dwFlags Private Const MMIO_FINDPROC = &H40000 ' Searches for the specified I/O procedure. Private Const MMIO_GLOBALPROC = &H10000000 ' This flag is a modifier to the MMIO_INSTALLPROC flag and indicates the I/O procedure should be installed for global use. This flag is ignored if MMIO_FINDPROC or MMIO_REMOVEPROC is specified. Private Const MMIO_INSTALLPROC = &H10000 ' Installs the specified I/O procedure. Private Const MMIO_REMOVEPROC = &H20000 ' Removes the specified I/O procedure. ' Constants - mmioInstallIOProc.fccIOProc Private Const MEY = &H2059454D ' This is the value of "MEY " run through FOURCC ' Constants - General Private Const DeviceAlias As String = "AviFile" Private Const AviCaption As String = "AVI.MEY+" ' Local Variables Private lpAVI As Long Private SizeAVI As Long Private blnOpen As Boolean ' Win32 API - DLL Functions Public Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal BytesToCopy As Long) Public Declare Function FindResource Lib "KERNEL32" Alias "FindResourceA" (ByVal hInstance As Long, ByVal lpName As String, ByVal lpType As String) As Long Public Declare Function LoadResource Lib "KERNEL32" (ByVal hInstance As Long, ByVal hResInfo As Long) As Long Public Declare Function LockResource Lib "KERNEL32" (ByVal hResData As Long) As Long Public Declare Function LoadLibrary Lib "KERNEL32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long Public Declare Function FreeLibrary Lib "KERNEL32" (ByVal hLibModule As Long) As Long Public Declare Function SizeofResource Lib "KERNEL32" (ByVal hInstance As Long, ByVal hResInfo As Long) As Long ' Win32 API - MCI Functions 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 mmioInstallIOProc Lib "winmm.dll" Alias "mmioInstallIOProcA" (ByVal fccIOProc As Long, ByVal pIOProc As Long, ByVal dwFlags As Long) As Long ' Win32 API - Misc Functions Private Declare Function GetWindowText Lib "USER32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal strText As String, ByVal TextLength As Long) As Long Private Declare Function SetWindowText Lib "USER32" Alias "SetWindowTextA" (ByVal hWnd As Long, ByVal strText As String) As Long 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX '============================================================================================================= ' ResAVI_Close ' ' Purpose : ' Closes the AVI video, and frees up any memory associated with it. ' ' Param Use ' ------------------------------------ ' 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 ResAVI_Close(Optional ByVal WaitToComplete As Boolean = True, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Close the AVI file ResAVI_Stop WaitToComplete, ShowErrors ResAVI_SendCommand "close " & DeviceAlias, , , WaitToComplete, ShowErrors ' Get rid of the reference to the CALLBACK function If mmioInstallIOProc(MEY, 0, MMIO_REMOVEPROC) <> 0 Then ResAVI_Close = True End If ' Reset variables lpAVI = 0 SizeAVI = 0 blnOpen = False End Function '============================================================================================================= ' ResAVI_CloseAll ' ' Purpose : ' Closes all devices opened by the current program, and frees up any memory associated with those device. ' ' Param Use ' ------------------------------------ ' 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 ResAVI_CloseAll(Optional ByVal WaitToComplete As Boolean = True, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Close all AVI files previously opened by this program ResAVI_Stop WaitToComplete, ShowErrors ResAVI_SendCommand "close all", , , WaitToComplete, ShowErrors ' Get rid of the reference to the CALLBACK function If mmioInstallIOProc(MEY, 0, MMIO_REMOVEPROC) <> 0 Then ResAVI_CloseAll = True End If ' Reset variables lpAVI = 0 SizeAVI = 0 blnOpen = False End Function '============================================================================================================= ' ResAVI_MoveVideo ' ' Purpose : ' This method allows you to manipulate the playback of the AVI file. You can use this method to move ' the location of the popup window playing the video, to modify the source coordinates of the video to give ' the effect of zooming in, or to modify the destination coordinates of the video to give the effect of ' zoming out. ' ' Param Use ' ------------------------------------ ' MoveWindowLocation Optional. If set to TRUE, the popup window will be moved according to the next 4 params ' Window_Left Optional. Specifies the coordinates of the left edge of the popup window after it's moved ' Window_Top Optional. Specifies the coordinates of the top edge of the popup window after it's moved ' Window_Width Optional. Specifies the new width of the popup window after it's moved ' Window_Height Optional. Specifies the new height of the popup window after it's moved ' DisplayVideoOnEntireWindow Optional. If set to TRUE, the entire window is used to display the video media. ' Otherwise the following 4 params are used to specify where on the window to display the ' video. ' Dest_Left Optional. Specifies the coordinates of the left edge of the video display location ' Dest_Top Optional. Specifies the coordinates of the top edge of the video display location ' Dest_Width Optional. Specifies the new width of the video display area ' Dest_Height Optional. Specifies the new height of the video display area ' UseEntireSourceImage Optional. If set to TRUE, the entire source image is used to display the video media. ' Otherwise the following 4 params are used to specify the source of the display. ' Source_Left Optional. Specifies the coordinates of the left edge of the source of the display ' Source_Top Optional. Specifies the coordinates of the top edge of the source of the display ' Source_Width Optional. Specifies the new width of the source of the display ' Source_Height Optional. Specifies the new height of the source of the display ' 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 ResAVI_MoveVideo(Optional ByVal MoveWindowLocation As Boolean = False, Optional ByVal Window_Left As Long, Optional ByVal Window_Top As Long, Optional ByVal Window_Width As Long, Optional ByVal Window_Height As Long, Optional ByVal DisplayVideoOnEntireWindow As Boolean = True, Optional ByVal Dest_Left As Long, Optional ByVal Dest_Top As Long, Optional ByVal Dest_Width As Long, Optional ByVal Dest_Height As Long, Optional ByVal UseEntireSourceImage As Boolean = True, Optional ByVal Source_Left As Long, Optional ByVal Source_Top As Long, Optional ByVal Source_Width As Long, Optional ByVal Source_Height As Long, Optional ByVal WaitToComplete As Boolean = False, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Validate parameters If blnOpen = False Then Exit Function ' Restores the original window/client and displays if not already displayed If ResAVI_SendCommand("put " & DeviceAlias & " window", , , WaitToComplete, ShowErrors) = False Then Exit Function If ResAVI_SendCommand("put " & DeviceAlias & " window client", , , WaitToComplete, ShowErrors) = False Then Exit Function ' Set the source of the image If UseEntireSourceImage = True Then If ResAVI_SendCommand("put " & DeviceAlias & " source", , , WaitToComplete, ShowErrors) = False Then Exit Function Else If ResAVI_SendCommand("put " & DeviceAlias & " source at " & CStr(Source_Left) & " " & CStr(Source_Top) & " " & CStr(Source_Width) & " " & CStr(Source_Height), , , WaitToComplete, ShowErrors) = False Then Exit Function End If ' Move and resize the window to the supplied dimentions If MoveWindowLocation = True Then If ResAVI_SendCommand("put " & DeviceAlias & " window at " & CStr(Window_Left) & " " & CStr(Window_Top) & " " & CStr(Window_Width) & " " & CStr(Window_Height), , , WaitToComplete, ShowErrors) = False Then Exit Function End If ' Set the destination of the video If DisplayVideoOnEntireWindow = True Then If ResAVI_SendCommand("put " & DeviceAlias & " destination", , , WaitToComplete, ShowErrors) = False Then Exit Function Else If ResAVI_SendCommand("put " & DeviceAlias & " destination at " & CStr(Dest_Left) & " " & CStr(Dest_Top) & " " & CStr(Dest_Width) & " " & CStr(Dest_Height), , , WaitToComplete, ShowErrors) = False Then Exit Function End If ' Operations completed successfully ResAVI_MoveVideo = True End Function '============================================================================================================= ' MCI_Open ' ' Purpose : ' Opens the specified AVI resource from the already opened library and assigns it an alias. After calling ' OPEN, you can then make other calls to it. ' ' *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 ' ------------------------------------ ' hLib The handle to the library file from which to extract the AVI resource. This is returned ' from a call to the LoadLibrary API. ' intResourceID The ID of the resource to load. The default for the first is 101, the second 102, etc. ' strResourceType Optional. The name of the section under which the AVI resource is stored in the specified ' resource library. The default for Visual Basic is "CUSTOM", but "AVI" is most commonly used. ' 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. ' 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) ' 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 ResAVI_Open(ByVal hLib As Long, ByVal intResourceID As Integer, Optional ByVal strResourceType As String = "AVI", Optional ByVal Shareable As Boolean = False, 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 ShowErrors As Boolean = False) As Boolean Dim OpenString As String Dim strResID As String Dim hRes As Long Dim hAVI As Long ' Validata parameters If hLib = 0 Then Exit Function If intResourceID < 1 Or intResourceID > 32767 Then Exit Function If strResourceType = "" Then Exit Function ' Close any previous AVI that was played ResAVI_CloseAll ' Put the resource ID into the correct form strResID = "#" & CStr(intResourceID) ' Load the resource specified and get the pointer to the memory address where it's stored hRes = FindResource(hLib, strResID & Chr(0), strResourceType & Chr(0)) If hRes = 0 Then Exit Function hAVI = LoadResource(hLib, hRes) If hAVI = 0 Then Exit Function lpAVI = LockResource(hAVI) If lpAVI = 0 Then Exit Function SizeAVI = SizeofResource(hLib, hRes) If SizeAVI = 0 Then Exit Function ' Install a CALLBACK function to handle the processing of the AVI while it's being played If mmioInstallIOProc(MEY, AddressOf MMIOProc, MMIO_INSTALLPROC + MMIO_GLOBALPROC) = 0 Then Exit Function ' Open the MCI device according to the specified parameters OpenString = "open " & AviCaption & " type avivideo alias " & DeviceAlias & " wait" 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 ' Open the device according to the parameters set If ResAVI_SendCommand(OpenString, , , False, ShowErrors) = True Then blnOpen = True ResAVI_Open = True End If End Function '============================================================================================================= ' ResAVI_Pause ' ' Purpose : ' Pauses the playback of the AVI resource. ' ' Param Use ' ------------------------------------ ' 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 ResAVI_Pause(Optional ByVal WaitToComplete As Boolean = False, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Validate parameters If blnOpen = False Then Exit Function ' Pause the device ResAVI_Pause = ResAVI_SendCommand("pause " & DeviceAlias, , , WaitToComplete, ShowErrors) End Function '============================================================================================================= ' ResAVI_Play ' ' Purpose : ' Starts the playback of the AVI resource. ' ' Param Use ' ------------------------------------ ' 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. ' 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 ResAVI_Play(Optional ByVal SpecifyStartPosition As Boolean = False, Optional ByVal StartPosition As Long, Optional ByVal SpecifyEndPosition As Boolean = False, Optional ByVal EndPosition As Long, Optional ByVal PlayFullScreen As Boolean = False, Optional ByVal RepeatPlay As Boolean = False, Optional ByVal WaitToComplete As Boolean = False, Optional ByVal ShowErrors As Boolean = False) As Boolean Dim PlayString As String ' Validate parameters If blnOpen = False 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" ' Play the device ResAVI_Play = ResAVI_SendCommand(PlayString, , , WaitToComplete, ShowErrors) End Function '============================================================================================================= ' ResAVI_Resume ' ' Purpose : ' Resumes the play of paused AVI resource. ' ' Param Use ' ------------------------------------ ' 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 ResAVI_Resume(Optional ByVal WaitToComplete As Boolean = False, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Validate parameters If blnOpen = False Then Exit Function ' Resume the device ResAVI_Resume = ResAVI_SendCommand("resume " & DeviceAlias, , , WaitToComplete, ShowErrors) End Function '============================================================================================================= ' ResAVI_Seek ' ' Purpose : ' Skips the current position of the playback ahead (or back) to the specified seek position. ' ' Param Use ' ------------------------------------ ' SeekPosistion Specifies the seek position to skip to. ' 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 ResAVI_Seek(ByVal SeekPosistion As Long, Optional ByVal WaitToComplete As Boolean = True, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Validate parameters If blnOpen = False Then Exit Function ' Seek to the specified position of the file ResAVI_Seek = ResAVI_SendCommand("seek " & DeviceAlias & " to " & CStr(SeekPosistion), , , WaitToComplete, ShowErrors) End Function '============================================================================================================= ' ResAVI_SeekBeginning ' ' Purpose : ' Moves the current play position to the beginning of the AVI. ' ' Param Use ' ------------------------------------ ' 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 ResAVI_SeekBeginning(Optional ByVal WaitToComplete As Boolean = True, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Validate parameters If blnOpen = False Then Exit Function ' Seek to the beginning of the file ResAVI_SeekBeginning = ResAVI_SendCommand("seek " & DeviceAlias & " to start", , , WaitToComplete, ShowErrors) End Function '============================================================================================================= ' ResAVI_SeekEnd ' ' Purpose : ' Moves the current play position to the end of the AVI. ' ' Param Use ' ------------------------------------ ' 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 ResAVI_SeekEnd(Optional ByVal WaitToComplete As Boolean = True, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Validate parameters If blnOpen = False Then Exit Function ' Seek to the end of the file ResAVI_SeekEnd = ResAVI_SendCommand("seek " & DeviceAlias & " to end", , , WaitToComplete, ShowErrors) End Function '============================================================================================================= ' ResAVI_Set ' ' Purpose : ' Alters the AVI device or AVI playback by sending the specified command to it. Not all commands are ' compatible with all multimedia systems. 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 ' ------------------------------------ ' 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. ' 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: Meaning: 'ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ 'audio all on/off Disables or enables audio output. Video-overlay devices, the MCISEQ sequencer, ' and the MCIWAVE waveform-audio device do not support this flag. 'audio left on/off 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. 'audio right on/off 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. 'door closed Retracts the tray and closes the door, if possible. For VCRs, loads the tape ' automatically. 'door open Opens the door and ejects the tray or tape, if possible. 'file format Specifies a file format that is used for save or capture commands. If omitted, ' this might default to a device driver defined format. If the specified file ' format conflicts with the currently selected algorithm and quality, then they ' are changed to the defaults for the file format. The following file formats ' are defined: ' AVI - Specifies AVI format ' AVSS - Specifies AVSS format ' DIB - Specifies DIB format ' JFIF - Specifies JFIF format ' JPEG - Specifies JPEG format ' MPEG - Specifies MPEG format ' RDIB - Specifies RLE DIB format ' RJPEG - Specifies RJPEG format 'seek exactly on/off Selects one of two seek modes. With "seek exactly on", seek will always move to ' the frame specified. With "seek exactly off", seek will move to the closest key ' frame prior to the frame specified. 'speed Sets the relative speed of video and audio playback from the workspace. Factor ' is the ratio between the nominal frame rate and the desired frame rate, where ' the nominal frame rate is designated as 1000. (A rate of 500 is half normal ' speed, 2000 is twice normal speed, and so on.) Setting the speed to zero plays ' the video as fast as possible without dropping frames and without audio. 'still file format Specifies the file format used for capture commands. 'time format frames Sets the time format to frames. All commands that use position values will assume ' frames. When the device is opened, frames is the default mode. Supported by ' videodiscs using CAV format. 'time format milliseconds Sets the time format to milliseconds. All commands that use position values will ' assume milliseconds. You can abbreviate milliseconds as "ms". For sequencer ' devices, the sequence file sets the default format to PPQN or SMPTE. Video-overlay ' devices do not support this flag. 'video on/off Enables or disables video output ' '============================================================================================================= Public Function ResAVI_Set(ByVal ControlSettingString As String, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Validate parameters If blnOpen = False Then Exit Function ' Set the specified device information ResAVI_Set = ResAVI_SendCommand("set " & DeviceAlias & " " & ControlSettingString, , , True, ShowErrors) End Function '============================================================================================================= ' ResAVI_Status ' ' Purpose : ' Retrieves the specified information about the AVI device or AVI playback by sending the specified status ' request command to it. Not all commands are compatible with all multimedia systems. See table below for details. ' ' *NOTE - This function makes the application wait for the device status to be retrieved because it must finish ' getting the status before the information returned by it can be used successfully ' ' Param Use ' ------------------------------------ ' StatusRequestString Specifies the status type being requested in the form of a string. The status can be ' any of the statuses in the following list ' Return_Status Returns the status requested in the "StatusRequestString" parameter in the form of a string. ' 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 status request strings: '============================================================================================================= 'StatusRequestString: Meaning: 'ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ 'audio Returns "on" or "off" depending on the most recent setaudio "on" or "off" command. ' It returns "on" if either or both speakers are enabled, and "off" otherwise. 'audio alignment Returns the alignment of data blocks relative to the start of input waveform-audio ' data. 'audio bitspersample Returns the number of bits per sample the device uses for recording. This flag ' applies only to devices supporting the "pcm" algorithm. 'audio breaks Returns the number of times the audio portion of the last AVI sequence broke up. ' The system counts an audio break whenever it attempts to write audio data to the ' device driver and discovers that the driver has already played all of the available ' data. This flag is recognized only by the MCIAVI digital-video driver. It is meant ' for performance evaluation only; the return value is difficult to interpret. 'audio bytespersec Returns the average number of bytes per second used for recording. 'audio input Returns the approximate instantaneous audio level of the analog input audio signal. ' A value greater than 1000 implies clipping distortion. Some devices can return this ' value only while recording audio. The value has no associated set or setaudio command. 'audio record Returns "on" or "off", reflecting the state set by setaudio "record". 'audio samplespersec Returns the number of samples per second recorded. 'audio source Returns the current audio digitizer source: "left", "right", "average", or "stereo". 'audio stream Returns the current audio-stream number. 'bass Returns the current audio-bass level. 'bitsperpel Returns the number of bits per pixel for saving captured or recorded data. 'brightness Returns the current video-brightness level. 'color Returns the current color level. 'contrast Returns the current contrast level. 'current track Returns the current track. The MCISEQ sequencer returns 1. 'disk space Returns the approximate disk space, in the current time format, that can be obtained ' by a reserve command for the specified disk drive. The drive is usually specified as ' a single letter or a single letter followed by a colon (:). Some devices, however, ' might use a path. 'file completion Returns the estimated percentage a load, save, capture, cut, copy, delete, paste, or ' undo operation has progressed. (Applications can use this to provide a visual ' indicator of progress.) 'file format Returns the current file format for record or save commands. 'file mode Returns "loading", "saving", "editing", or "idle". During a load operation, it returns ' "loading". During save and capture operations, it returns "saving". During cut, copy, ' delete, paste, or undo operations, it returns "editing". 'forward Returns TRUE if the play direction is forward or if the device is not playing. 'frames skipped Returns the number of frames that were not drawn when the last AVI sequence was played. ' This flag is recognized only by the MCIAVI digital-video driver. It is meant for ' performance evaluation only; the return value is difficult to interpret. 'gamma Returns the value set with setvideo "gamma to" value. 'input Returns the input set. If one is not set, the error returned indicates that any device ' can be used. For AVIVideo devices, modifies the "bass", "treble", "volume", ' "brightness", "color", "contrast", "gamma", "sharpness", or "tint" flag so that it ' applies only to the input. This is the default when monitoring the input. 'left volume Returns the volume set for the left audio channel. 'length Returns the total length of the media, in the current time format. For PPQN files, ' the length is returned in song pointer units. For SMPTE files, it is returned as ' hh:mm:ss:ff, where hh is hours, mm is minutes, ss is seconds, and ff is frames. 'length track Returns the length of the track, in time or frames, specified by number. For PPQN ' files, the length is returned in song pointer units. For SMPTE files, it is returned ' as hh:mm:ss:ff, where hh is hours, mm is minutes, ss is seconds, and ff is frames. 'media present Returns TRUE if the media is inserted in the device or FALSE otherwise. Sequencer, ' video-overlay, digital-video, and waveform-audio devices return TRUE. 'mode Returns the current mode of the device. All devices can return the following modes: ' "not ready" ' "paused" ' "playing" ' "stopped" ' Some devices can return the additional following modes: ' "open" ' "parked" ' "recording" ' "seeking" 'monitor Returns "file" or "input". The returned value indicates the current presentation source. 'monitor method Returns "pre", "post", or "direct". The returned value indicates the method used for ' input monitoring. 'nominal The item modifies the "bass", "brightness", "color", "contrast", "gamma", "sharpness", ' "tint", "treble," and "volume" flags to return the nominal value instead of the current ' setting. 'nominal frame rate Returns the nominal frame rate associated with the file. The units are in frames per ' second multiplied by 1000. 'nominal record frame rate Returns the nominal frame rate associated with the input video signal. The units are ' in frames per second multiplied by 1000. 'number of tracks Returns the number of tracks on the media. The MCISEQ and MCIWAVE devices return 1, ' as do most VCR devices. The MCIPIONR device does not support this flag. 'output Returns the currently set output. If no output is set, the error returned indicates ' that any device can be used. For digital-video devices, modifies the "bass", "treble", ' "volume", "brightness", "color", "contrast", "gamma", "sharpness", or "tint" flag so ' that it applies only to the output. This is the default when monitoring a file. 'pause mode Returns "recording" if the device is paused while recording. It returns "playing" if ' the device is paused while playing. It returns the error "Action not applicable in ' current mode" if the device is not paused. 'play speed Returns a value representing how closely the actual playing time of the last AVI ' sequence matched the target playing time. The value 1000 indicates that the target ' time and the actual time were the same. A value of 2000, for example, would indicate ' that the AVI sequence took twice as long to play as it should have. This flag is ' recognized only by the MCIAVI digital-video driver. It is meant for performance ' evaluation only; the return value is difficult to interpret. 'position Returns the current position. For PPQN files, the position is returned in song ' pointer units. For SMPTE files, it is returned as hh:mm:ss:ff, where hh is hours, ' mm is minutes, ss is seconds, and ff is frames. 'position track Returns the position of the start of the track specified by number. For PPQN files, ' the time format is returned in song pointer units. For SMPTE files, it is returned ' as hh:mm:ss:ff, where hh is hours, mm is minutes, ss is seconds, and ff is frames. ' The MCISEQ sequencer returns zero. The MCIPIONR device does not support this flag. ' The MCIWAVE device returns zero. 'ready Returns TRUE if the device is ready to accept another command. 'record frame rate Returns the frame rate, in frames per second multiplied by 1000, used for compression. 'reference frame Returns the frame number for the nearest key frame image that precedes the specified ' frame. 'reserved size Returns the size, in the current time format, of the reserved workspace. The size ' corresponds to the approximate time it would take to play the compressed data ' from a full workspace. It returns zero if there is no reserved disk space. This flag ' returns the approximate size because the precise disk space for compressed data cannot, ' in general, be predicted until after the data has been compressed. 'right volume Returns the volume set for the right audio channel. 'samplespersec Returns the number of samples per second played or recorded. 'seek exactly Returns "on" or "off", indicating whether or not the "seek exactly" flag is set. 'sharpness Returns the current sharpness level of the device. 'smpte Returns the SMPTE timecode associated with the current position in the workspace. ' This is a string with the form dd:dd:dd:dd, where each d denotes a digit from 0 to 9. ' If the workspace data does not include timecode data, then this flag returns 00:00:00:00. 'speed Returns the current speed of the device in frames per second (or in the same format ' used by the set "speed" command). The MCIPIONR videodisc player does not support this ' flag. 'start position Returns the starting position of the media. 'still file format Returns the current file format for the capture command. 'time format Returns the current time format. For more information, see the time formats in the set ' command. 'tint Returns the current video-tint level. 'treble Returns the current audio-treble level. 'unsaved Returns TRUE if there is recorded data in the workspace that might be lost as a result ' of a close, load, record, reserve, cut, delete, or paste command. Returns FALSE ' otherwise. 'video Returns "on" or "off", reflecting the state set by the setvideo command. 'video key color Returns the value for the key color. 'video key index Returns the value for the key index. 'video record Returns "on" or "off", reflecting the current state set by setvideo "record". 'video source Returns the video-source type. For more information, see the setvideo command. 'video source number Returns a number corresponding to the video source of the type in use. For example, ' it returns 2 if the second NTSC video source input is being used. 'video stream Returns the current video-stream number. 'volume Returns the average volume to the left and right speaker. This returns an error if ' the device has not been played or volume has not been set. 'window handle Returns ASCII decimal value for the window handle in the low-order word of the ' return value. 'window maximized Returns TRUE if the window is maximized. 'window minimized Returns TRUE if the window is minimized. 'window visible Returns TRUE if the window is not hidden. ' '============================================================================================================= Public Function ResAVI_Status(ByVal StatusRequestString As String, ByRef Return_Status As String, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Validate parameters If blnOpen = False Then Exit Function ' Clear the return variable Return_Status = "" ' Get the device status requested ResAVI_Status = ResAVI_SendCommand("status " & DeviceAlias & " " & StatusRequestString, True, Return_Status, True, ShowErrors) End Function '============================================================================================================= ' ResAVI_Stop ' ' Purpose : ' Stops the playback of the specified device. Note that this does NOT reset the current position in the ' media being played to the beginning. To do that, make a call to the "ResAVI_SeekBeginning" method. ' ' Param Use ' ------------------------------------ ' 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 ResAVI_Stop(Optional ByVal WaitToComplete As Boolean = False, Optional ByVal ShowErrors As Boolean = False) As Boolean ' Validate parameters If blnOpen = False Then Exit Function ' Stop the device ResAVI_Stop = ResAVI_SendCommand("stop " & DeviceAlias, , , WaitToComplete, ShowErrors) End Function '============================================================================================================= ' MCI_WindowCaption ' ' Purpose : ' This function changes the caption of the window that is displaying any type of VIDEO playback. ' ' Param Use ' ------------------------------------ ' strNewWindowCaption Specifies the new window caption to be set. ' 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 ResAVI_WindowCaption(ByVal strNewWindowCaption As String, Optional ByVal ShowErrors As Boolean = False) As Boolean Dim hWindow As Long Dim strReturn As String ' Validate parameters If blnOpen = False Then Exit Function ' Get the window handle, and if valid... use to change the caption If ResAVI_Status("window handle", strReturn, ShowErrors) = True Then If strReturn <> "" Then If IsNumeric(strReturn) = True Then hWindow = CLng(strReturn) If SetWindowText(hWindow, strNewWindowCaption & Chr(0)) <> 0 Then ResAVI_WindowCaption = True End If End If End If End Function '============================================================================================================= ' ResAVI_SendCommand ' ' Purpose : ' This function allows you to send commands right to the MCI multimedia system. ' ' Param Use ' ------------------------------------ ' CommandString Specifies the command to send to the MCI system. ' UseReturnString Optional. If set to TRUE, this function attempts to caption a return value. Not all ' commands have a return value, but if one is returned, it will be returned via ' the "Return_Result" parameter. ' Return_Result Optional. If the "UseReturnString" parameter is set to TRUE, then this parameter returns ' whatever the MCI system returned from the API call. ' 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 ResAVI_SendCommand(ByVal CommandString As String, Optional ByVal UseReturnString As Boolean = False, Optional ByRef Return_Result As String, Optional ByVal WaitToComplete As Boolean = True, Optional ByVal ShowErrors As Boolean = False) As Boolean Dim ReturnValue As Long ' Set the default return value Return_Result = "" ' Make sure parameters are valid CommandString = Trim(CommandString) If CommandString = "" Then Exit Function If InStr(CommandString, Chr(0)) > 0 Then CommandString = Left(CommandString, InStr(CommandString, Chr(0)) - 1) If WaitToComplete = True And InStr(UCase(CommandString), " WAIT") = 0 Then CommandString = CommandString & " wait" CommandString = CommandString & Chr(0) ' Call the mciSendString API with the specified command string If UseReturnString = False Then ReturnValue = mciSendString(CommandString, 0, 0, 0) Else Return_Result = String(260, Chr(0)) ReturnValue = mciSendString(CommandString, Return_Result, 260, 0) Return_Result = Left(Return_Result, InStr(Return_Result, Chr(0)) - 1) End If ' Check for errors If GetLastErr_MCI(ReturnValue, "mciSendString", , , ShowErrors) = False Then ResAVI_SendCommand = True End Function 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ' This is the CALLBACK function that is used with the "mmioInstallIOProc" API to manipulate an AVI being played from memory Public Function MMIOProc(ByRef lpMMIOInfo As MMIOINFO, ByVal uMessage As Long, ByVal lParam1 As Long, ByVal lParam2 As Long) As Long Static blnOpened As Boolean Select Case uMessage Case MMIOM_OPEN If blnOpened = False Then blnOpened = True lpMMIOInfo.lDiskOffset = 0 End If MMIOProc = 0 Case MMIOM_CLOSE MMIOProc = 0 Case MMIOM_READ: Call CopyMemory(ByVal lParam1, ByVal lpAVI + lpMMIOInfo.lDiskOffset, lParam2) lpMMIOInfo.lDiskOffset = lpMMIOInfo.lDiskOffset + lParam2 MMIOProc = lParam2 Case MMIOM_SEEK Select Case lParam2 Case SEEK_SET lpMMIOInfo.lDiskOffset = lParam1 Case SEEK_CUR lpMMIOInfo.lDiskOffset = lpMMIOInfo.lDiskOffset + lParam1 lpMMIOInfo.lDiskOffset = SizeAVI - 1 - lParam1 Case SEEK_END lpMMIOInfo.lDiskOffset = SizeAVI - 1 - lParam1 End Select MMIOProc = lpMMIOInfo.lDiskOffset Case Else MMIOProc = -1 End Select End Function 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ' Get the error that just occured (if one did occur) Private Function GetLastErr_MCI(Optional ByVal ErrorNumber As Long, Optional ByVal LastAPICalled As String = "last", Optional ByRef Return_ErrNum As Long, Optional ByRef Return_ErrDesc As String, Optional ByVal ShowErrors As Boolean = False) As Boolean Dim intErrorNumber As Integer ' Clear return variables Return_ErrNum = 0 Return_ErrDesc = "" ' If no error occured, exit If ErrorNumber = 0 Then Exit Function Else intErrorNumber = LOWORD(ErrorNumber) End If ' Assign initial values GetLastErr_MCI = True Return_ErrNum = CLng(intErrorNumber) If LastAPICalled = "" Then LastAPICalled = "last" ' Get the error description based on the error number Return_ErrDesc = String(260, Chr(0)) If mciGetErrorString(Return_ErrNum, Return_ErrDesc, 260) <> 0 Then Return_ErrDesc = Left(Return_ErrDesc, InStr(Return_ErrDesc, Chr(0)) - 1) Else Return_ErrDesc = "Unknown Error" End If ' If specified to show an error message, do so If ShowErrors = True Then MsgBox "The following error occured while calling the " & LastAPICalled & " MCI API:" & Chr(13) & Chr(13) & _ "Error Number = " & Return_ErrNum & Chr(13) & _ "Error Description = " & Return_ErrDesc, vbOKOnly + vbExclamation, " MCI ERROR" End If End Function ' Function that extracts the "Low Order" (lower 16bits) of a 32bit number Private Function LOWORD(ByVal dwValue As Long) As Integer LOWORD = Val("&H" & Right("0000" & Hex(dwValue), 4)) End Function ' Function that extracts the "High Order" (upper 16bits) of a 32bit number Private Function HIWORD(ByVal dwValue As Long) As Integer HIWORD = Val("&H" & Left(Right("00000000" & Hex(dwValue), 8), 4)) End Function