用vb怎样实现单击一个按钮触发一个声音文件
3个回答
展开全部
Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long '声明API函数
'声明常量 下面是这个函数的dwFlags参数的常用值
Const SND_SYNC = &H0 '声音同步播放
Const SND_ASYNC = &H1 '声音非同步播放
Const SND_NODEFAULT = &H2 '如果声音文件不存在也不产生错误
Const SND_FILENAME = &H20000 '声音是文件类型
r = PlaySound( "D:\示例.wav", 0&, SND_ASYNC Or AND_FILENAME Or SND_NODEFAULT)
写这么明白 应该了解了吧
'声明常量 下面是这个函数的dwFlags参数的常用值
Const SND_SYNC = &H0 '声音同步播放
Const SND_ASYNC = &H1 '声音非同步播放
Const SND_NODEFAULT = &H2 '如果声音文件不存在也不产生错误
Const SND_FILENAME = &H20000 '声音是文件类型
r = PlaySound( "D:\示例.wav", 0&, SND_ASYNC Or AND_FILENAME Or SND_NODEFAULT)
写这么明白 应该了解了吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Public Function MediaPlayer(ByVal Controls As WindowsMediaPlayer, ByVal File, Optional Volume = 50, Optional ByVal Visible = 0)
Controls.Visible = Visible
Controls.settings.Volume = Volume
Controls.URL = File
Controls.Controls.play
End Function
'以上放到模块中
添加一个windowsmediaplayer控件
调用MediaPlayer,方法如下
Private Sub Form_Load()
MediaPlayer WindowsMediaPlayer1, "1.mp3", 100, 0 '控件名,文件路径,音量最大100,0隐藏或1显示控件
End Sub
Controls.Visible = Visible
Controls.settings.Volume = Volume
Controls.URL = File
Controls.Controls.play
End Function
'以上放到模块中
添加一个windowsmediaplayer控件
调用MediaPlayer,方法如下
Private Sub Form_Load()
MediaPlayer WindowsMediaPlayer1, "1.mp3", 100, 0 '控件名,文件路径,音量最大100,0隐藏或1显示控件
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Const SND_ASYNC = &H1 ' play asynchronously
Private Sub Command1_Click()
PlaySound "C:\WINDOWS\Media\ding.wav", 0, SND_ASYNC
End Sub
Private Const SND_ASYNC = &H1 ' play asynchronously
Private Sub Command1_Click()
PlaySound "C:\WINDOWS\Media\ding.wav", 0, SND_ASYNC
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询