'Module MPEG,AVI,sequencer,audio source code
'All Functions in this Module will return a value
'if the Function success or not.
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String, ByVal uLength As Long) As Long
Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Dim glo_hWnd As Long
Dim glo_from As Long
Dim glo_to As Long
Public Function OpenMPEG(hwnd As Long, Filename As String, TypeDevice As String) As String
'Callig OpenMPEG will open the multimedia file
'Parameters
'hWnd
'[in]handle of the window
'which you want to play in. you can put handle for
'your desktop if you want to playing movie in your desktop.
'filename
'[in]Specifies file name and the path it can contain any space
'which you want to play.
'typeDevice
'[in] Specifies a type of MCI device and it could be from the following:
'Type MCI description driver file
'sequencer dealing with mid mciseq.drv
' files
'MPEGVideo dealing with most multimedia mciqtz.drv
' like mpg,mp3,mp2..
' au,aiff,..etc also support
' avi,vob(for DVD),midi,mid
' and rmi files.because of this
' my advice to you to use
' type "MPEGVideo" to playing
' MOST FILES even avi!!
' I got this info from my
' experiment when I opened
' System.ini in section MCI
' Then I must share others.
'avivideo deling with avi movie mciavi.drv
'the following types if you had ATI RAGE II or Later
'(This VGA Card to Support DVD Video)
'DvdVideo This support DVD's Video MciCinem.drv DVD
'ATIMPEGVIDEO to playing MPEG Video mciatim1.drv
'But my advice to you to not use type "ATIMPEGVIDEO" & "DvdVideo" because
'Type MPEGVideo can support most Multimedia files and also support DVD's
'Video if you had ATI RAGE II or LATER.
'last note for DVD Video: you must have a fast computer
'note : Type "MpegVideo" support these extensions:
'qt , mov, dat,snd, mpg, mpa, mpv, enc, m1v, mp2,mp3, mpe, mpeg, mpm
'au , snd, aif, aiff, aifc,wav,wmv,wma,avi,midi,mid,rmi,avi,etc.
'Note if there are any new type in (system.ini in windows 98 or in registry in windows 2000)
'it will supported by Type "MPEGVideo" because of this use type "MPEGVideo" to playing
'Most Files and remember you can use sequencer for mid and avivideo for avi,,etc.
'Now you must note using Type "MPEGVideo" can playing all Multimedia files
'Note : if this Function success will return value string "Success"
'or if not will return value string description the error which occur
'Okay make sure if you used this function don't forget to use function
'CloseMPEG When you will end your program or you
'will got error message
Dim cmdToDo As String * 255
Dim dwReturn As Long
Dim ret As String * 128
Dim tmp As String * 255
Dim lenShort As Long
Dim ShortPathAndFie As String
lenShort = GetShortPathName(Filename, tmp, 255)
ShortPathAndFie = Left$(tmp, lenShort)
glo_hWnd = hwnd
cmdToDo = "open " & ShortPathAndFie & " type " & TypeDevice & " Alias mpeg parent " & hwnd & " Style 1073741824"
dwReturn = mciSendString(cmdToDo, 0&, 0&, 0&)
If Not dwReturn = 0 Then 'not success
mciGetErrorString dwReturn, ret, 128
OpenMPEG = ret: OpenMPEG = "Type not Supported!": Exit Function
End If
OpenMPEG = "Success"
End Function
Public Function PlayMPEG(from_where As String, to_where As String) As String
'calling PlayMPEG will playing the multimedia file
'the first parameter for from where playing file
'the second parameter for to where playing file
'if the first parameter is vbNullString and the second parameter is vbNullString the Function Will:
'playing from the beginning to end.
'if the first parameter is 10 and the second parameter is 100 the Function Will:
'playing from 10 to 100 and stop.
'if the first parameter is vbNullString and the second parameter is 100 the Function Will:
'playing from the beginning to 100 and stop.
'if the first parameter is 104 and the second parameter is vbNullString the Function Will:
'playing from 104 to end.
'Note :the numbers 10,100,104 is an example for from playing to where end playing
'Note : if this Function success will return value string "Success"
'or if not will return value string description the error which occur
If from_where = vbNullString And to_where = vbNullString Then
glo_from = 1
glo_to = GetTotalFrames
ElseIf Not from_where = vbNullString And Not to_where = vbNullString Then
glo_from = from_where
glo_to = to_where
ElseIf Not from_where = vbNullString And to_where = vbNullString Then
glo_from = from_where
glo_to = GetTotalFrames
ElseIf from_where = vbNullString And Not to_where = vbNullString Then
glo_from = 1
glo_to = to_where
End If
Dim cmdToDo As String * 255
Dim dwReturn As Long
Dim ret As String * 128
cmdToDo = "play mpeg from " & glo_from & " to " & glo_to
dwReturn = mciSendString(cmdToDo, 0&, 0&, 0&)
If Not dwReturn = 0 Then 'not success
mciGetErrorString dwReturn, ret, 128
PlayMPEG = ret
Exit Function
End If
PlayMPEG = "Success"
End Function
Public Function CloseMPEG() As String
'calling CloseMPEG will close the multimedia file
'you must call this function if you call OpenMPEG
'And want to close your program or you will get an
'error message
'Note : if this Function success will return value string "Success"
'or if not will return value string description the error which occur
Dim dwReturn As Long
Dim ret As String * 128
dwReturn = mciSendString("Close mpeg", 0&, 0&, 0&)
If Not dwReturn = 0 Then 'not success
mciGetErrorString dwReturn, ret, 128
CloseMPEG = ret
Exit Function
End If
CloseMPEG = "Success"
End Function
Public Function PauseMPEG() As String
'calling PauseMPEG will pause the multimedia file
'Note : if this Function success will return value string "Success"
'or if not will return value string description the error which occur
Dim dwReturn As Long
Dim ret As String * 128
dwReturn = mciSendString("Pause mpeg", 0&, 0&, 0&)
If Not dwReturn = 0 Then 'not success
mciGetErrorString dwReturn, ret, 128
PauseMPEG = ret
Exit Function
End If
PauseMPEG = "Paused"
End Function
Public Function StopMPEG() As String
'calling StopMPEG will Stop the multimedia file
'Note : if this Function success will return value string "Success"
'or if not will return value string description the error which occur
Dim dwReturn As Long
Dim ret As String * 128
dwReturn = mciSendString("Stop mpeg", 0&, 0&, 0&)
If Not dwReturn = 0 Then 'not success
mciGetErrorString dwReturn, ret, 128
StopMPEG = ret
Exit Function
End If
StopMPEG = "Success"
End Function
Public Function ResumeMPEG() As String
'calling ResumeMPEG will Resume the multimedia file
'Note : if this Function success will return value string "Success"
'or if not will return value string description the error which occur
Dim dwReturn As Long
Dim ret As String * 128
dwReturn = mciSendString("Resume mpeg", 0&, 0&, 0&)
If Not dwReturn = 0 Then 'not success
mciGetErrorString dwReturn, ret, 128
ResumeMPEG = ret
Exit Function
End If
ResumeMPEG = "Success"
End Function