' -=-=-=- METHODS -=-=-=-=-
' mmOpen FilenameOpens the requested filename
' mmCloseCloses the current file
' mmPausePauses playback of the current file
' mmStopStops playback ready for closedown
' mmSeek PositionSeeks to a position in the file
' mmPlayPlays the open file
'-------------------------------------------------------------
' NOTES
' -----
'
' Open a file, then play it. Pause it in response to a request
' from the user. Stop if you intend to seek to the start and
' play again. Close when you no longer want to play the file
'--------------------------------------------------------------
Private sAlias As String' Used internally to give an alias name to
' the multimedia resource
Private sFilename As String' Holds the filename internally
Private nLength As Single' Holds the length of the filename
' internally
Private nPosition As Single' Holds the current position internally
Private sStatus As String' Holds the current status as a string
Private bWait As Boolean' Determines if VB should wait until play
' is complete before returning.
'------------ API DECLARATIONS -------------
'note that this is all one code line:
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
Public Sub mmOpen(ByVal sTheFile As String)
' Declare a variable to hold the value returned by mciSendString
Dim nReturn As Long
' Declare a string variable to hold the file type
Dim sType As String
' Opens the specified multimedia file, and closes any
' other that may be open
If sAlias"" Then
mmClose
End If
' Determine the type of file from the file extension
Select Case UCase$(Right$(sTheFile, 3))
Case "WAV"
sType = "Waveaudio"
Case "AVI"
sType = "AviVideo"
Case "MID"
sType = "Sequencer"
Case Else
' If the file extension is not known then exit the subroutine
Exit Sub
End Select
sAlias = Right$(sTheFile, 3)Minute(Now)
' At this point there is no file open, and we have determined the
' file type. Now would be a good time to open the new file.
' Note: if the name contains a space we have to enclose it in quotes
If InStr(sTheFile, " ") Then sTheFile = Chr(34)sTheFileChr(34)
nReturn = mciSendString("Open "sTheFile" ALIAS "sAlias _
" TYPE "sType" wait", "", 0, 0)
End Sub
Public Sub mmClose()
' Closes the currently opened multimedia file
' Declare a variable to hold the return value from the mciSendString
' command
Dim nReturn As Long
' If there is no file currently open then exit the subroutine
If sAlias = "" Then Exit Sub
nReturn = mciSendString("Close "sAlias, "", 0, 0)
sAlias = ""
sFilename = ""
End Sub
Public Sub mmPause()
' Pause playback of the file
' Declare a variable to hold the return value from the mciSendString
' command
Dim nReturn As Long
' If there is no file currently open then exit the subroutine
If sAlias = "" Then Exit Sub
nReturn = mciSendString("Pause "sAlias, "", 0, 0)
End Sub
Public Sub mmPlay()
' Plays the currently open file, from the current position
' Declare a variable to hold the return value from the mciSendString
' command
Dim nReturn As Long
' If there is no file currently open, then exit the routine
If sAlias = "" Then Exit Sub
' Now play the file
If bWait Then
nReturn = mciSendString("Play "sAlias" wait", "", 0, 0)
Else
nReturn = mciSendString("Play "sAlias, "", 0, 0)
End If
End Sub
Public Sub mmStop()
' Stop using a file totally, be it playing or whatever
推荐阅读
- word如何打开纠错提示,如何打开word的纠错
- 快手如何买推广8元的商品,快手怎么买推广便宜
- pdf如何选择性打印,pdf选择范围打印
- thinkphpfetch模板,thinkphp 模块
- vb.net图片转二进制 vb编写二进制转十进制
- html5添加图片地址,如何在html中添加图片的地址怎么写
- 怎样不痴迷网络游戏作文,如何做到不沉迷游戏
- 对幼儿冒险游戏的看法论文,对幼儿参与冒险性游戏的研究
- linux中ls-a命令 linux中ls lh