如何在vb中加载声音
我想用一个时钟控件控制一段声音的播放,假如在3-5秒内,我应该怎么写程序。我有一段程序,不知道错在哪里,请各位指教'工程---引用----WindowsMediaPlay...
我想用一个时钟控件控制一段声音的播放,假如在3-5秒内,我应该怎么写程序。我有一段程序,不知道错在哪里,请各位指教
'工程---引用----WindowsMediaPlayer---确定.加声音
Dim XX As WindowsMediaPlayer
Private Sub Form_Load()
Set XX = New WindowsMediaPlayer
XX.openPlayer "D:\My Documents\My Music\音乐\xb.mp3"
End Sub
提示错误是实时错误
自动化错误 展开
'工程---引用----WindowsMediaPlayer---确定.加声音
Dim XX As WindowsMediaPlayer
Private Sub Form_Load()
Set XX = New WindowsMediaPlayer
XX.openPlayer "D:\My Documents\My Music\音乐\xb.mp3"
End Sub
提示错误是实时错误
自动化错误 展开
2个回答
展开全部
不用wmp。
用API就行了 简单又不占资源 加载一个WMP要很多内存以及CPU时间。
Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Public Const SND_ASYNC = &H1 '异步
播放:
PlaySound "wav File Path", 0, SND_ASYNC
用API就行了 简单又不占资源 加载一个WMP要很多内存以及CPU时间。
Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Public Const SND_ASYNC = &H1 '异步
播放:
PlaySound "wav File Path", 0, SND_ASYNC
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询