vb.net+语音播放 vbs语音( 二 )


My.Computer.Audio.Play(My.Resources.xxxmusic1xxx, AudioPlayMode.Background)
我用二进制读取了声音文件,VB或VB.net如何播放二进制声音数据,请高手赐教!不明白你为什么要二进制读取声音文件vb.net+语音播放,VB可以直接调用API播放声音文件 , 不需要你二进制来读取声音文件vb.net+语音播放的 。
Private
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA"
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub PlayWavFile(strFileName As String, PlayCount As Long, JianGe As Long)
'strFileName 要播放的文件名(带路径)
'playCount 播放的次数
'JianGe多次播放时,每次的时间间隔
If Len(Dir(strFileName)) = 0 Then Exit Sub
If PlayCount = 0 Then Exit Sub
If JianGe1000 Then JianGe = 1000
DoEvents
sndPlaySound strFileName, 16 + 1
Sleep JianGe
Call PlayWavFile(strFileName, PlayCount - 1, JianGe)
End Sub
Private Sub Form_Click()
PlayWavFile "C:\aaa.wav", 1, 1000 '参数vb.net+语音播放:播放文件,播放次数,播放间隔
End Sub
vb.net中如何控制MP3播放先定义api函数
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrRetumString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Sub mnu_Music_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_Music.Click
mciSendString("open c:\1.mp3 alias mp3", Nothing, 0, IntPtr.Zero)
mciSendString("Play mp3", Nothing, 0, IntPtr.Zero)
End Sub
上面2行代码就可以播放了 , 测试通过 。
就是没有其它功能,自己加上吧,
如:关闭mciSendString("close mp3",Nothing,0,intPtr.Zero)
等等
关于vb.net+语音播放和vbs语音的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读