发表于:2006-05-29 09:33:00
楼主
感谢caojunyi提供!
播放语音文件(.WAV)可以通过API函数来进行,不需要单独的编写。播放WAV文件的函数有两个,对应于同步和异步。
所谓同步是指一次只能播放一个语音文件,不可以连续播放;而异步则可以同时打开多个语 音文件,一个个连续的播放,在多个报警同时到来时非常有用。
同步函数为:mciSendString
使用时首先要声明: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
用法:
Dim filename as String
Dim cmd As String
filename = "test.wav" cmd = "open " & filename & " type WAVEAudio alias MyWav" Call mciSendString(cmd, 0, 0, 0)
Call mciSendString("play MyWav", 0, 0, 0)
异步函数为:mciSendString
使用时首先要声明:Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA"
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
用法:
Dim filename as String
filename = "test.wav"
Call sndPlaySound(filename, SND_SYNC)
可以连续调用sndPlaySound来进行连续多个语音文件的播放。