vb中如何添加背景音乐?
我是个新手,做了个管理系统,想在界面上添加背景音乐,mp3格式的,就是窗口一点开音乐就可以循环播放,请问具体该怎么做?我要具体的方案哦,谢谢啦~~...
我是个新手,做了个管理系统,想在界面上添加背景音乐,mp3格式的,就是窗口一点开音乐就可以循环播放,请问具体该怎么做?我要具体的方案哦,谢谢啦~~
展开
11个回答
展开全部
WindowsMediaPlayer1.Controls.play'播放
WindowsMediaPlayer1.Controls.stop'停止
WindowsMediaPlayer1.Controls.pause'暂停
你这样连续让它播放\停止\暂停,它最后就是停止了,当然没有声音啦
Private
Sub
WindowsMediaPlayer1_OpenStateChange(ByVal
NewState
As
Long)
WindowsMediaPlayer1.URL
=
"e:\wj\j.mp3"
WindowsMediaPlayer1.Controls.play
End
Sub
就可以了
WindowsMediaPlayer1.Controls.stop'停止
WindowsMediaPlayer1.Controls.pause'暂停
你这样连续让它播放\停止\暂停,它最后就是停止了,当然没有声音啦
Private
Sub
WindowsMediaPlayer1_OpenStateChange(ByVal
NewState
As
Long)
WindowsMediaPlayer1.URL
=
"e:\wj\j.mp3"
WindowsMediaPlayer1.Controls.play
End
Sub
就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你不是要加背景音乐吗?
Private
Sub
Form_Load()
WindowsMediaPlayer1.Visible
=
False
WindowsMediaPlayer1.URL
=
"e:\mp3\1.mp3"
End
Sub
这样,那个WindowsMediaPlayer不会出现在你的下雪画面中,又能实现背景音乐的播放了.
Private
Sub
Form_Load()
WindowsMediaPlayer1.Visible
=
False
WindowsMediaPlayer1.URL
=
"e:\mp3\1.mp3"
End
Sub
这样,那个WindowsMediaPlayer不会出现在你的下雪画面中,又能实现背景音乐的播放了.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
'下面仅以播放背景音乐为例
'在窗体代码中复制以下代码,并改变歌曲名称,运行后就会听到美妙的音乐了。
'====窗体代码部分====
Option Explicit
Dim a
Private Sub Form_Load()
Set a = CreateObject("wmplayer.ocx")
a.url = "E:\mp3\花好月圆.mp3" '你可在此改成你的乐曲
a.settings.playCount = 99999
End Sub
Private Sub Form_Unload(Cancel As Integer)
a.Controls.stop
a.Close
Set a = Nothing
End Sub
'在窗体代码中复制以下代码,并改变歌曲名称,运行后就会听到美妙的音乐了。
'====窗体代码部分====
Option Explicit
Dim a
Private Sub Form_Load()
Set a = CreateObject("wmplayer.ocx")
a.url = "E:\mp3\花好月圆.mp3" '你可在此改成你的乐曲
a.settings.playCount = 99999
End Sub
Private Sub Form_Unload(Cancel As Integer)
a.Controls.stop
a.Close
Set a = Nothing
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
背景音乐干吗要用控件
api就行了
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
Dim
Res
As
Integer,
Ret
As
String
*
1024
Private
Sub
Form_Click()
Dim
Res
As
Integer,
Ret
As
String
*
1024
Res
=
mciSendString("play
"
&
"F:\我的音乐\DJ串烧一条龙.mp3",
Ret,
1024,
0)
End
Sub
Private
Sub
Form_QueryUnload(Cancel
As
Integer,
UnloadMode
As
Integer)
Res
=
mciSendString("close
all",
Ret,
1024,
0)
End
End
Sub
api就行了
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
Dim
Res
As
Integer,
Ret
As
String
*
1024
Private
Sub
Form_Click()
Dim
Res
As
Integer,
Ret
As
String
*
1024
Res
=
mciSendString("play
"
&
"F:\我的音乐\DJ串烧一条龙.mp3",
Ret,
1024,
0)
End
Sub
Private
Sub
Form_QueryUnload(Cancel
As
Integer,
UnloadMode
As
Integer)
Res
=
mciSendString("close
all",
Ret,
1024,
0)
End
End
Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询